@KalaBhairava wrote:
Hi Every one,
i have 10 data sets (AA,BB,CC,DD,EE,FF,GG,HH) in one library and i want create macro to convert data set name into variable name (New ).
for ex: for AA data set i want variable New =AA
for BB data set i want variable New =BB;
please give me a solution.
Would you walk up to someone and say "please give me a solution"?
%macro addName(indsn=, outdsn=, varName=);
data &outdsn.;
set &indsn;
&varName = "&indsn.";
run;
%mend;
%addName(indsn=AA, outdsn=AA_New, varName=);
Now to call it for all data sets in a library, use CALL EXECUTE and SASHELP.VTABLE.
data demo;
set sashelp.vtable;
where libname = 'CDISCXX'; *can add filtering conditions here;
str = catt('%addName(indsn=',
memname,
', outdsn=',
catx("_", memname, "new"),
", varName=New",
");"
);
call execute(str);
run;
Make sure str is being calculated correctly after you've test it.
In general, first make sure your base code is working and then you can convert any program into a macro using this approach.
Good Luck.
https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md
PS. "please give me a solution" isn't something most people would ever say, it's more likely you intended to say "please help me with this problem", because this isn't a coding service where you're entitled to a solution or someone will write the code for you, this is a community of volunteers who you're asking for help. I'm going to assume that this is a just a translation issue.
@KalaBhairava wrote:
Hi Every one,
i have 10 data sets (AA,BB,CC,DD,EE,FF,GG,HH) in one library and i want create macro to convert data set name into variable name (New ).
for ex: for AA data set i want variable New =AA
for BB data set i want variable New =BB;
please give me a solution.
... View more