Hi,
For ex:- there are 16 variables in x dataset. If we use proc contents , we can see all the variables in the output window.
But, if I want to insert all these variables into one single macro variable, is there any way.
If i call that macro variable, we need to get all the 16 variables.
Any help is appreciated.
Thanks in advance,
Mano.
If you want the variable names separated by spaces you get that from the output of PROC CONTENTS.
proc contents data=x noprint out=contents; run;
proc sql noprint ;
select name into :varlist separated by ' '
from contents ;
quit;
%put Variables are: &varlist ;
do you want any kind of delimiter, like for the heading of a CSV file?
do you want variables or variable values?
If you want the variable names separated by spaces you get that from the output of PROC CONTENTS.
proc contents data=x noprint out=contents; run;
proc sql noprint ;
select name into :varlist separated by ' '
from contents ;
quit;
%put Variables are: &varlist ;
Thank you Tom.
skip the contents
%let Lib_Data = sashelp.class;
PROC SQL; select Name
into :List_names separated by ' '
from dictionary.columns
where Libname eq "%upcase(%scan(&Lib_Data,1,.))"
and Memname eq "%upcase(%scan(&Lib_Data,2,.))"
;
quit;
%put note: list_names = &List_names;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.