But a workaround way is using RESOLVE() or SYMGETN().
%let var1=205;
%let var2=306;
%let var3=409;
data mvtemp;
input var $ note $;
new_var1=input(resolve(var),best.);
new_var2=symgetn(compress(var,'&.'));
datalines;
&var1. X
&var2. Xx
&var3. YYY
;
run;
Unfortunately, DATALINES or CARDS does not support macro variable ,you need put these macro variable into a text file ,and read this text file .
This feature has already been mentioned in sas documentation.
But a workaround way is using RESOLVE() or SYMGETN().
%let var1=205;
%let var2=306;
%let var3=409;
data mvtemp;
input var $ note $;
new_var1=input(resolve(var),best.);
new_var2=symgetn(compress(var,'&.'));
datalines;
&var1. X
&var2. Xx
&var3. YYY
;
run;
Thanks, It works.
I take from prev. post. The code below is ok also.
%let mvars=&_ref_1.@&_ref_2.@&_ref_3.@&_ref_4.@&_ref_5.@&_ref_6.@&_ref_7.@&_ref_8.@&_ref_9.;
%let mvars2=max@min@max@min@max@min@max@min@max;
data &indexout._&dt._mm_ind;
do i= 1 to countw(symget('mvars'),'@');
length mm_indx note $8. ;
mm_indx=scan(symget('mvars'),i,'@');
note=scan(symget('mvars2'),i,'@');
output;
end;
run;quit;
I am not sure what you mean by "stack". But it looks like you want to resolve a series of macro variables with the same base name and a numeric suffix. Why not use SYMGET() function?
data mvtemp;
length var $32 ;
var = symget(cats('var',_n_));
input note $8.;
cards;
X
Xx
YYY
;
Or since it looks like the values of the VARxx macro variables have digit strings perhaps you want to use SYMGETN() instead?
data mvtemp;
value = symgetn(cats('var',_n_));
input note $8.;
cards;
X
Xx
YYY
;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.