Help using Base SAS procedures

Proc Contents

Reply
N/A
Posts: 0

Proc Contents

Hi All-

Is it possible to suppress the Engine/Host and Attribute information and have only the variable information? If so, how can this be done?

Also under Proc Compare, is it possible to have "Dataset Summary" only and suppress other two variable and observation summary?

Any help would be appreciated.

Thanks,
Priya
SAS Super FREQ
Posts: 8,869

Re: Proc Contents

Posted in reply to deleted_user
Hi:
Take a look at the ODS SELECT statement. For example, if you use ODS TRACE ON/ODS TRACE OFF to get the name of your output object of interest, then you can select just that output object.

For example, if I run this code, on SAS 9.2:
[pre]
ods trace on / label;
proc contents data=sashelp.class;
run;
ods trace off;
[/pre]

Then I find in the LOG that the output object for the VARIABLES information is:
[pre]
Output Added:
-------------
Name: Variables
Label: Variables
Template: Base.Contents.Variables
Path: Contents.DataSet.Variables
Label Path: 'The Contents Procedure'.'SASHELP.CLASS'.'Variables'
-------------
[/pre]

So, now, I can SELECT only the VARIABLES output object for my output, by modifying the original PROC CONTENTS step to be:
[pre]
ods listing;
ods select variables;
proc contents data=sashelp.class;
run;
[/pre]

You can use this method (ODS TRACE to get the output object name and then ODS SELECT to only get that output object in your result file) for any procedure that produces output objects -- either tabular or graphical output objects in order to select (or exclude) just your output object of interest.

Note that the ODS SELECT statement must be placed IMMEDIATELY before your procedure of choice. For example, this would be unacceptable because PROC PRINT does not create a VARIABLES output object:
[pre]
ods listing;
ods select variables;

proc print data=sashelp.class;
run;

proc contents data=sashelp.class;
run;
[/pre]

and would produce this warning in the LOG:
[pre]
WARNING: Output 'variables' was not created. Make sure that the output object name, label, or
path is spelled correctly. Also, verify that the appropriate procedure options are
used to produce the requested output object. For example, verify that the NOPRINT
option is not used.

[/pre]

cynthia
N/A
Posts: 0

Re: Proc Contents

Posted in reply to Cynthia_sas
Thanks, Cynthia. That helped.

Also any suggestions regarding my question about Proc Compare: to supress variable and observation summary and to display only Dataset summary?

Thanks,
Priya
N/A
Posts: 0

Re: Proc Contents

Posted in reply to deleted_user
Never mind, the same concept of ODS trace on/off works for Proc Compare too...Thanks for your help.
Ask a Question
Discussion stats
  • 3 replies
  • 625 views
  • 0 likes
  • 2 in conversation