Hi,
I am a noob concerning SAS programming. I came across a clustering method that i am applying to some sample data. I need a macro to contain a list of variable names and each time i call it it brings them, like a vector of some sort. Anyone keen on macro programming?
Here is the pdf i found with the clustering technique(http://support.sas.com/resources/papers/proceedings13/068-2013.pdf), in page 4 it says :
"The macros all_name and sm_name refer to the list of the variables of product frequencies and
the corresponding list of variables to be standardized (preceded by SM_), respectively"
Any help is welcome.
Thank you. Gd day to ye !
Hi.
Would something like this work?
(I am using sashelp.class)
*select the variable names once in the list all_name then in sm_name - to be later used for standardization
proc sql;
select name, compress("sm_" ||name) into: all_name separated by " ",
: sm_name separated by " "
from dictionary.columns
where libname = "SASHELP" & memname = "CLASS" & name not in ("Name", "Sex");
quit;
data temp;
set sashelp.class ;
keep &all_name. &sm_name. name ;
array avar {*} &all_name. ;
array svar {*} &sm_name. ;
do i = 1 to dim(avar);
svar(i) = avar(i);
end;
run;
Good luck!
Anca.
Hi.
Would something like this work?
(I am using sashelp.class)
*select the variable names once in the list all_name then in sm_name - to be later used for standardization
proc sql;
select name, compress("sm_" ||name) into: all_name separated by " ",
: sm_name separated by " "
from dictionary.columns
where libname = "SASHELP" & memname = "CLASS" & name not in ("Name", "Sex");
quit;
data temp;
set sashelp.class ;
keep &all_name. &sm_name. name ;
array avar {*} &all_name. ;
array svar {*} &sm_name. ;
do i = 1 to dim(avar);
svar(i) = avar(i);
end;
run;
Good luck!
Anca.
Hey anca,
Anca, romanian girl name i'm guessing :smileygrin:, nice !
Thank you for your feedback.
I tried the given code with some modifications. to add 3 more extra tables. I need to use them to keep the univariate analysis results. It gave me the name as requested.
I will carry and try on applying it to the rest needed to see if it fits in the whole process right.
Thank you very much, seems to work.
I'll be back if i have any other requests :smileysilly:
Gd day to you
Glad it worked.
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.