The first step of the script uses `PROC SQL` to query the `dictionary.columns` metadata table. It selects all column names from the `SASUSER.HOUSES` dataset and stores them in a macro variable named `varlist`, with each column name separated by a space. The second step calls `PROC PRINT` to display the content of the `SASUSER.HOUSES` dataset. Using the `VAR &varlist` clause allows only the columns whose names have been dynamically retrieved and stored in the macro variable to be displayed, thus ensuring a customizable display of the data.
Data Analysis
Type : MIXED
The script queries the `dictionary.columns` system table to obtain metadata about the columns. It then uses the `SASUSER.HOUSES` dataset, which is a typical dataset in the SAS environment, often available by default or through examples.
1 Code Block
PROC SQL
Explanation : This block uses `PROC SQL` in `noprint` mode to query the `dictionary.columns` system view. It selects all column names from the `SASUSER.HOUSES` dataset and concatenates them into the `varlist` macro variable, each name separated by a space, for later use in the script.
Copied!
proc sql noprint;
select name into :varlist separated by " "
from dictionary.columns
where upcase(libname)="SASUSER" and upcase(memname)="HOUSES"
order by name;
quit;
1
PROC SQL noprint;
2
select name into :varlist separated BY" "
3
from dictionary.columns
4
where upcase(LIBNAME)="SASUSER" and upcase(memname)="HOUSES"
5
order BY name;
6
QUIT;
2 Code Block
PROC PRINT
Explanation : This block executes `PROC PRINT` to display data from the `sasuser.houses` dataset. The `VAR &varlist;` clause uses the `varlist` macro variable created previously to dynamically specify the columns to display, thereby allowing only the selected columns to be viewed.
Copied!
proc print data=sasuser.houses ;
var &varlist;
run;
1
2
PROC PRINT
3
DATA=sasuser.houses ;
4
var &varlist;
5
RUN;
6
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.
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.