BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tianerhu
Pyrite | Level 9
/*Step 3: Creating sas data sets*/

 /*CDM datasets*/

%macro CDM (Domain= ) ;

PROC IMPORT DATAFILE= "&root./data/data_excel/CDM/&domain..xlsx"
            DBMS=XLSX OUT= CDM.&domain  ;
     GETNAMES=YES;
RUN;

%mend CDM ;

in the parentheses, what is 'Domain='? what role is it ?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Search:  @Sas.com %macro statement

https://www.google.com/search?q=%40sas.com+%25macro+statement

 

Read:  https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1nypovnwon4uyn159rst8pgzqrl.htm

 

The text inside the () in the %MACRO statement defines the parameters to the macro.

So in this %CDM() macro DOMAIN is the name of the parameter.

The equal sign means that you must pass the value by name when calling the macro.   So if you wanted to run the %CDM macro for the AE domain you would use:

 

%cdm(domain=ae)

If you remove the equal sign in the %MACRO statement

 

%macro cdm(domain);

 

then you could have passed the value for DOMAIN in the call to the macro just by its position. 

%cdm(ae)

Note that even if you define the macro such that a parameter may be passed by position you can always pass the values by name.  So %cdm(domain=ae) will work with either way of defining the DOMAIN parameter.

 

 

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

It is a macro parameter, which is used like a macro variable in the macro.

And since it is a named parameter, it must also be supplied as such when the macro is called:

%cdm(domain=xxx)
tianerhu
Pyrite | Level 9
Thank you for your help.
Tom
Super User Tom
Super User

Search:  @Sas.com %macro statement

https://www.google.com/search?q=%40sas.com+%25macro+statement

 

Read:  https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1nypovnwon4uyn159rst8pgzqrl.htm

 

The text inside the () in the %MACRO statement defines the parameters to the macro.

So in this %CDM() macro DOMAIN is the name of the parameter.

The equal sign means that you must pass the value by name when calling the macro.   So if you wanted to run the %CDM macro for the AE domain you would use:

 

%cdm(domain=ae)

If you remove the equal sign in the %MACRO statement

 

%macro cdm(domain);

 

then you could have passed the value for DOMAIN in the call to the macro just by its position. 

%cdm(ae)

Note that even if you define the macro such that a parameter may be passed by position you can always pass the values by name.  So %cdm(domain=ae) will work with either way of defining the DOMAIN parameter.

 

 

tianerhu
Pyrite | Level 9
thank for your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1176 views
  • 0 likes
  • 3 in conversation