How to generate a new macro variable for each row?
Data ConsentInfo&j.;
length record $4000;
set info_1;
i=_n_;
record=cats("'", '{ "firstName" : ',' "',firstName,'", ',' "lastName" : ','"',lastName,'", ','"email" :',
'"',email,'"}',"'");
call symputx('NewRecord',record,'g');
run;
Are you asking how to USE the macro variables once you have them?
You can type their full name:
%put &NewRecord1 ;
%put &NewRecord2 ;
You can use another macro variable to help you build up the name you want to reference. You will need to double up the first &. The && will be converted to & and signal to the macro processor to scan the text again to resolve the resulting macro variable reference.
%let i=1;
%put &&NewRecord&i ;
You have to use a different macro variable NAME to prevent writing the same macro variable over and over.
call symputx(cats('NewRecord',i),record,'g');
Is it possible to add a %put NewRecord || i;
If after that I do a call execute how can I passed each macro variable
Are you asking how to USE the macro variables once you have them?
You can type their full name:
%put &NewRecord1 ;
%put &NewRecord2 ;
You can use another macro variable to help you build up the name you want to reference. You will need to double up the first &. The && will be converted to & and signal to the macro processor to scan the text again to resolve the resulting macro variable reference.
%let i=1;
%put &&NewRecord&i ;
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!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.