|
Thanks to the input from several Toby, David, Ed, Jack, and others, I
put together the program below to create multiple variables from one
variable using array statement and some macro. I have four such
variables to process. Is there a way to substitute the array name with a
macro name so that I can use one set of commands instead of four? When I
checked the online SAS help files, I was not able to find information
concerning both array and macro.
Libin
%let varnam=Q26;
proc sql;
select length into :varlen
from dictionary.columns
where libname='WORK' and memname='TAB1' and Upcase(name)="&varnam";
%put variable name: &varnam variable length= &varlen;
quit;
data tabq26 ( Drop = I );
set tab1;
Array Q26_(&varlen) ;
Do I = 1 to &varlen;
If Not (Verify(Strip(Put(I , 8. -L)) , &varnam)) Then Do ;
Q26_(I) = 1 ;
End ;
Else Do ;
Q26_(I) = 0 ;
End;
End;
Run;
|