BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
M_A_C
Calcite | Level 5

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 !

1 ACCEPTED SOLUTION

Accepted Solutions
AncaTilea
Pyrite | Level 9

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.

View solution in original post

5 REPLIES 5
AncaTilea
Pyrite | Level 9

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.

M_A_C
Calcite | Level 5

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.

M_A_C
Calcite | Level 5

Thank you very much, seems to work.

I'll be back if i have any other requests :smileysilly:

Gd day to you Smiley Wink

AncaTilea
Pyrite | Level 9

Glad it worked.

Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1074 views
  • 0 likes
  • 2 in conversation