BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hellohere
Pyrite | Level 9

I need save out dataset info with ODS/PROC CONTENTS, but do not like the flush over in "Results Viewer"[it will choke up the window]. 

 

How to do it?! Thanks, 

 


169526      proc contents data=sashelp.baseball ;
169527         ods output Variables=_cont_tgt;
169528      run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds

NOTE: The data set WORK._CONT_TGT has 24 observations and 7 variables.

169529      proc contents data=sashelp.baseball noprint;
169530         ods output Variables=_cont_tgt;
169531      run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

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.
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

As the error message says, if you use NOPRINT you can't get the ODS OUTPUT to work. Instead, you need to close the output destination. or exclude output from being written.

 

ods exclude all;
proc contents data=sashelp.baseball;
ods output Variables=_cont_tgt;
run;
ods exclude none;

 

 

or

 

 

ods _all_ close;
proc contents data=sashelp.baseball;
ods output Variables=_cont_tgt;
run;
ods html; /* If you want more output later, you need to turn on the destination, which could be html or listing or pdf or excel or other */
--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

As the error message says, if you use NOPRINT you can't get the ODS OUTPUT to work. Instead, you need to close the output destination. or exclude output from being written.

 

ods exclude all;
proc contents data=sashelp.baseball;
ods output Variables=_cont_tgt;
run;
ods exclude none;

 

 

or

 

 

ods _all_ close;
proc contents data=sashelp.baseball;
ods output Variables=_cont_tgt;
run;
ods html; /* If you want more output later, you need to turn on the destination, which could be html or listing or pdf or excel or other */
--
Paige Miller
ballardw
Super User

Depending on what you want in the data set you might be better off looking at the SASHELP.VCOLUMN, or with Proc SQL Dictionary.columns

 

data _cont_tgt;
   set sashelp.vcolumns;
   where libname='SASHELP' and memname='BASEBALL' and memtype='DATA';
run;

Sashelp.vcolumns is a view SAS maintains of all the data set and views variables for all the currently defined libraries.

The libname, memname (set name) and memtype  are stored in uppercase so you select that.

There may be more variables in the result than you actually need. Keep the ones you want.

hellohere
Pyrite | Level 9
Thanks, How to do with Proc SQL Dictionary.columns?!
Tom
Super User Tom
Super User

Just skip the ODS and use the normal way to output the data.

proc contents data=sashelp.baseball  noprint out=_cont_tgt;
run;

Which has the extra bonus of being a dataset that is designed to actually contain DATA instead of one that is just side effect of the printed output. 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1804 views
  • 2 likes
  • 4 in conversation