i have a data set like
data test;
input x y z;
..........
run;
i want a macro variable like x|y|z (concatenating the variable names)
is it possible in sas by proc sql or anyhow?
Hello,
with proc sql:
data test;
x=1;y=2;z=3;
run;
proc sql noprint;
select name into :allvars separated by '|' from sashelp.vcolumn
where libname='WORK' and memname='TEST';
quit;
Hello,
with proc sql:
data test;
x=1;y=2;z=3;
run;
proc sql noprint;
select name into :allvars separated by '|' from sashelp.vcolumn
where libname='WORK' and memname='TEST';
quit;
Do you want to concatenate the values of the variables into a new field? Or create a SAS macro variable with the variable names?
If the latter, try something like this:
If the former, then you can use one of the CAT functions (such as CATX) to create a new value in your DATA step:
newVal = CATX(' ',x,y,z);
That's not a macro var though. If you need the macro variable you'll need to decide which particular record you want to represent, calculate the value, and you can use CALL SYMPUT to stuff it into a macro variable for use later in your program.
Chris
Thanks a lot.
is there any document related to it. Please share.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.