SAS: How to output only the PROC CONTENTS part that displays the variables in the data set?

I am participating in the SAS class for beginners, and we only need to display the PROC CONTENTS output section, which shows the variables in the data set. For example, when you do

proc contents data=whas.heart3; run; 

Conclusion - 3 tables. The third table is called:

Alphabetical List of Variables and Attributes

I need to figure out how to modify the above code to display only that third table.

+6
source share
3 answers

Out put is delivered through an output delivery system (ODS). Use ods trace on; , and the system will inform you that it is being delivered. In this case, Variables is the table you are looking for.

Use ods select Variables; to tell ODS to ONLY deliver the variable table. Then reset to default ( ods select default; ) for other procedures.

 ods select Variables; proc contents data=mydata; run; ods select default; 
+9
source

I am not sure if ODS will be covered in the newbie. Another option is to check the online help for SAS procedures, here you will find that there is a SHORT option that can be used with PROC CONTENTS. This will simply display a list of variables.

 proc contents data=whas.heart3 short; run; 
+5
source

An alternative to using ODS is to use the PROC SQL dictionary. It is slower, but potentially more versatile.

 PROC SQL; SELECT varnum, name, type, length,format, informat FROM dictionary.columns WHERE upcase(libname)="WHAS" AND upcase(memname)="HEART3" ORDER BY varnum; QUIT; 

This can be useful when using more complex ODS parameters and is equivalent to

 ODS SELECT Variables; PROC CONTENTS varnum data=whas.heart3; RUN; ODS SELECT default; 
0
source

Source: https://habr.com/ru/post/954029/


All Articles