VARNUM checks whether the variable &name exists
data _null_;
tableid=open('mydata','i'); if (sasname("&name")) then do; citynum=varnum(tableid,"&name"); if (citynum=0) then call symput ('msg','The column is not in the table.'); else call symput ('msg','The column number is '|| citynum ); end; else call symput ('msg','Invalid SAS name--please reenter.');
run;
No comments:
Post a Comment