Dataset Proc数据集在一个步骤中修改多个数据集
我使用以下方法从数据集中删除标签:Dataset Proc数据集在一个步骤中修改多个数据集,dataset,sas,Dataset,Sas,我使用以下方法从数据集中删除标签: proc datasets lib=my_lib memtype=data nolist ; modify my_data_1 ; attrib _all_ label=' '; run; quit; 我想为几个数据集做这个,我的数据集,…,我的数据集。使用以下命令将返回错误(应为;,/): 我想知道是否有一种方法可以将例外应用于以下情况: proc datasets lib=my_lib memtype=data nolist ;
proc datasets lib=my_lib memtype=data nolist ;
modify my_data_1 ;
attrib _all_ label=' ';
run;
quit;
我想为几个数据集做这个,我的数据集,…,我的数据集。使用以下命令将返回错误(应为;,/):
我想知道是否有一种方法可以将例外应用于以下情况:
proc datasets lib=my_lib memtype=data nolist ;
modify _all_ ;
attrib _all_ label=' ';
run;
quit;
我要修改的数据集占大多数,这将更加有效。构建数据集为数据集及其上的变量分配标签 证明这是成功的
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
编写宏以从一个数据集中删除标签
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
将此宏应用于所涉及的数据集
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
证明这是成功的
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
构建数据集为数据集及其上的变量分配标签 证明这是成功的
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
编写宏以从一个数据集中删除标签
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
将此宏应用于所涉及的数据集
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
证明这是成功的
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
%macro eraseLabel(data);
proc datasets lib=WORK memtype=data nolist ;
modify &data. (label=' '); ** Remove label form dataset **;
attrib _all_ label=' '; ** Remove label form variable(s) **;
run;
quit;
%mend;
data _null_;
set sashelp.vtable;
where libname='WORK' and memname like 'MY_DATA%';
call execute('%eraseLabel('||memname||')');
run;
proc sql;
select memname, memlabel from sashelp.vtable
where libname='WORK' and memname like 'MY_DATA%';
select memname, name, label from sashelp.vcolumn
where libname='WORK' and memname like 'MY_DATA%';
run;
更简单的方法是使用复制和选择,例如:
proc datasets ;
copy in=sashelp out=work;
select cars baseball;
attrib _all_ label=' ';
run;
更简单的方法是使用复制和选择,例如:
proc datasets ;
copy in=sashelp out=work;
select cars baseball;
attrib _all_ label=' ';
run;
这里的另一种方法是构造对
proc数据集的单个调用
,该调用将使用多个运行一次完成所有操作代码>进程内的组。目标是构建如下内容:
data example1 example2;
set sashelp.class;
label sex = 'example label';
run;
proc datasets lib = work nolist;
modify example1;
attrib _all_ label = '';
run;
modify example2;
attrib _all_ label = '';
run;
quit;
这可以通过一个相当简单的宏循环或带有调用执行的数据步骤实现,例如
data _null_;
set sashelp.vtable end = eof;
where libname = 'WORK' and memtype = 'DATA' and memname eq: 'EXAMPLE';
if _n_ = 1 then call execute('proc datasets lib = work nolist nodetails;');
call execute(catx(' ','modify',memname,'; attrib _all_ label = ""; run;'));
if eof then call execute('quit;');
run;
这里的另一种方法是构造对proc数据集的单个调用
,该调用将使用多个运行一次完成所有操作代码>进程内的组。目标是构建如下内容:
data example1 example2;
set sashelp.class;
label sex = 'example label';
run;
proc datasets lib = work nolist;
modify example1;
attrib _all_ label = '';
run;
modify example2;
attrib _all_ label = '';
run;
quit;
这可以通过一个相当简单的宏循环或带有调用执行的数据步骤实现,例如
data _null_;
set sashelp.vtable end = eof;
where libname = 'WORK' and memtype = 'DATA' and memname eq: 'EXAMPLE';
if _n_ = 1 then call execute('proc datasets lib = work nolist nodetails;');
call execute(catx(' ','modify',memname,'; attrib _all_ label = ""; run;'));
if eof then call execute('quit;');
run;
编写宏do循环是否有帮助?编写宏do循环是否有帮助?是否可以使用此方法复制到同一个库中?是的。如果语法正确proc datasets lib=my_lib;复制选择“我的数据”:;属性标签='';运行代码>冒号是通配符。这比我对小数据集的回答要好。对于大型数据集,这太耗时了,因为您不仅要编辑数据集的元数据,还要复制完整的内容。是否可以使用此方法复制到同一个库中?是的。如果语法正确proc datasets lib=my_lib;复制选择“我的数据”:;属性标签='';运行代码>冒号是通配符。这比我对小数据集的回答要好。对于大型数据集,这太耗时了,因为您不仅要编辑数据集的元数据,还要复制完整的内容。