Say I want to create 100 new variables (x1, x2,,, x100) with %do %to loop, and x1 might be char and x2 might be numeric and so on, the following sample code strangely does not allow me to create x1 and x2 with different format: %macro format(); data test; %do i=1 %to 2; if &i.=1 then x&i.=1; if &i.=2 then x&i.="two"; %end; run; %mend; %format(); I have to change the code a little bit to get what I want: %macro format1(); data test1; %do i=1 %to 2; %if &i.=1 %then %do; x&i.=1; %end; %if &i.=2 %then %do; x&i.="two"; %end; %end; run; %mend; %format1(); so the questions are, 1) what is the reason behind the wierd behavior, and 2) is there is a way to do what I want, using only "if then" instead of "%if %then", as "%if %then" is so clumsy and I cannot really use it in more compleecated coding. Thanks.
... View more