We can check the variable existence before DATA step run time. The popular method is Macro technology with File I/O functions or Dictionary table.
How to avoid creating this variable if it does not exist and to get the formatted value of the variable if it exist.
Here ia another way:
* Sample;
data dummy;
set sashelp.class (obs=0);
run;
data test;
set sashelp.class;
if _n_ = 1 then do;
drop varexist dsid rc;
retain varexist;
dsid = open('dummy');
varexist = varnum(dsid, "name");
rc = close(dsid);
end;
length tmp $ 20;
if varexist then do;
tmp = vvaluex("name");
end;
else tmp = '';
run;
No comments:
Post a Comment