* GOAL: Within a macro, you want to create a new variable name. * It could then be used as a data set name, or a variable name to be assigned, etc.; %macro newname(dset=,varname=); * You have to make the new name before you use it in * another data statement; data _NULL_; L1=CATS("&varname","_Plus1"); CALL SYMPUT('namenew',L1); ; * Now you can use the variable name created by SYMPUT; DATA REVISED;SET &DSET; &namenew=&varname+1; run; %mend; Data try; input ABCD @@; datalines; 1 2 3 4 ;run; %newname(dset=try,varname=ABCD); proc print data=revised;run;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter