Hi, I am trying to check some variable with same prefix existing or not. If so, generate some other variable values. If not check the next one. variables start with "_" with a number. For example _25,_50. The interval is 25 but not all are existing. Some are missing. The code I wrote will generate all the variable even it is not exist. Can't find out the problem. Could anyone have a look? Thanks, Andrea The code: %macro test(); data test; set test_desc5 ; drop _name_ _label_; dsid=open('test_desc5'); %do i=25 %to 1500 %by 25; if varnum(dsid,'_&i.')^=0 then do; if _&i = '' then _&i = ''; if A&i = '' then A&i = .; end; %end; rc=close(dsid); drop rc dsid; run; %mend; %test; The data like: _25 _50 _100 . .....A0 A25 A100 ...... 0.7(0.4,1.5) 0.8(0.5,1.5) 0.9(0.6,1.6) ......10 20 30......... 0.6(0.3,1.4) 0.7(0.4,1.4) 0.8(0.5,1.5) ......20 30 40......... . . .
... View more