/*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 ?
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.
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)
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.
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!
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.