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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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