Hello everyone, I was wondering if there is a way to write dataset variable into a macro variable and use the macro variable within the same datastep. I have tried different approaches to do the following; but have been running into call symput, excute so far. Thanks for any help that might help to solve the situation... data atmp; input anID surfix $; datalines; 1 3_1 2 2_2 3 2_3 ; run; data atmpdt; input anID A_2_1 A_2_2 A_2_3 B_2_1 B_2_2 B_2_3; datalines; 1 0.1 0.2 0.3 0.4 0.5 0.6 2 1.1 1.2 1.3 1.4 1.5 1.6 3 2.1 2.2 2.3 2.4 2.5 2.6 ; run; %let prefixlist=A B; data atmp2; Merge atmp atmpdt; by anID; /*Intention: read current row variable surfix into the macro variable asurfix*/ call symput('Asurfix',surfix); nbvar = countw("&prefixlist"," "); /*Intention: for each name in the macro variable "prefixlist" create a dataset set variable initiliazed with the value in the var &aprefix._&Asurfix */ do count = 1 to nbvar; call symput('aprefix',scan("&prefixlist",count," ")); &aprefix=&aprefix._&Asurfix; end; run;
... View more