自动变量存在宏
我正在尝试技巧,以查看是否仍然存在变量并为其分配一个空值,
%macro VarExist(ds, var);
%local rc dsid result;
%let dsid =%sysfunc(open(&ds));
%if %sysfunc(varnum(&dsid,&var)) > 0 %then %do;
%let result =1;
%put NOTE: Var &var exists in &ds;
%end;
%else %do;
%let result= 0;
%put NOTE: Variable &var was dropped at SDTM level per CDISC Compliance.
Null value will be assigned.;
data AE2;
set work.&ds;
&VAR=.;
RUN;
%END;
%let rc=%sysfunc(close(&dsid));
%MEND VarExist;
%VarExist(ae1,AESDTH);
是否有一种方法可以自动分配变量实际字符/数字来源? vtype
也许或vvalue
?。另外,对于AE2,我可以做类似& ds.n
的事情,还是只是在原始& ds
dataset中自动分配它。我只做了另一个数据集,以进行现实测试。有什么想法吗?链接到相关论文?
I'm trying to finesse a macro I did to see if a variable is still present and to assign it a null value
%macro VarExist(ds, var);
%local rc dsid result;
%let dsid =%sysfunc(open(&ds));
%if %sysfunc(varnum(&dsid,&var)) > 0 %then %do;
%let result =1;
%put NOTE: Var &var exists in &ds;
%end;
%else %do;
%let result= 0;
%put NOTE: Variable &var was dropped at SDTM level per CDISC Compliance.
Null value will be assigned.;
data AE2;
set work.&ds;
&VAR=.;
RUN;
%END;
%let rc=%sysfunc(close(&dsid));
%MEND VarExist;
%VarExist(ae1,AESDTH);
Is there a way to automatically assign the variables actual character/numeric origin? vtype
maybe or vvalue
?. Also for the AE2, can I do something like &ds.n
or even just automatically assign it within the original &ds
dataset. I only did another dataset to reality test that it was working. Any thoughts? Links to relevant papers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎不需要测试该变量是否存在。
There does not appear to be any need to test if the variable exists or not.