The input data comes from the SASHELP.CARS table, an integrated SAS library that contains information about different car makes and models.
1 Code Block
PROC SQL
Explanation : This block uses the SQL procedure to query the SASHELP.CARS table. It selects the 'weight' column for all entries where 'make' is 'Acura' and 'model' is 'MDX'. The found value is then stored in a macro variable named MDX_WEIGHT. The `trimmed` option removes unnecessary whitespace, and `noprint` prevents the query output from being displayed in the output window.
Copied!
proc sql noprint;
select weight into :MDX_WEIGHT trimmed
from sashelp.cars
where strip(make)='Acura' and strip(model)='MDX';
quit;
1
PROC SQL noprint;
2
select weight into :MDX_WEIGHT trimmed
3
from sashelp.cars
4
where strip(make)='Acura' and strip(model)='MDX';
5
QUIT;
2 Code Block
MACRO/OPTIONS
Explanation : This code block is used to verify the successful creation of the macro variable. `options nosource` disables the display of SAS code in the log, while `options source` re-enables it. Between these two options, the `%put` macro is used to display a formatted character string in the SAS log, including the value of the MDX_WEIGHT macro variable, thereby confirming its value.
Copied!
* Verify the contents of the new macro variable by printing to the SAS log.;
options nosource;
%put ===================================;
%put The weight of an Acura MDX is &MDX_WEIGHT..;
%put ===================================;
options source;
1
* Verify the contents of the new macro variable by printing to the SAS log.;
2
options nosource;
3
%put ===================================;
4
%put The weight of an Acura MDX is &MDX_WEIGHT..;
5
%put ===================================;
6
options SOURCE;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : HANDS-ON WORKSHOP, Title: Using SAS Macro Variable Lists to Create Dynamic Data-Driven Programs, Instructor: Josh Horstman, Exercise: 02
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.