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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 4 replies
  • 752 views
  • 0 likes
  • 3 in conversation