BookmarkSubscribeRSS Feed
KevinViel
Pyrite | Level 9

The ODS OUTPUT statement documentation includes NOWARN.  I am scan a large directory and abstracting the metadata of the data sets using the CONTENTS procedure.  Although a SAS data set exists in some directories, it may not have variables or observations.  This occurs through a programming practice I would prohibit in my shop:

 

data test ;

  stop ;

run ;

 

How can I avoid the output variables not created warning?  I have tried variations on:

 

ods output variables = variables ( nowarn ) ;

 

 

Thank you,

 

Kevin

4 REPLIES 4
Astounding
PROC Star

Sometimes you'll see a hybrid like this:

 

data want;

   stop;

   set have;

run;

 

That gives you a data set with 0 observations, but with all variables defined.  Is it OK to omit the PROC CONTENTS for those too?

KevinViel
Pyrite | Level 9

Astounding,

 

  Correct, as does my preferred flavor:

 

data want ;

  if 0 then set have ;

run ;

 

(I use this, for instance, when obtaining the attributes for a hash, with a data set KEEP= option as appropriate.)

 

Both of these approaches create variables, assuming that have has variables.  CONTENTS did not "like" the absence of variables, but it reported the metadata with 0 observations.  I cannot control what "data sets" are in the directories.  I even found some files with a .sas7bdat extension that SAS did not recognize and reported something like

 

DM.AE.DATA

 

FWIW, %sysfunc( exist( DM.AE ))  was equal to 1 in that case.  I am not that interested in a "clean" log; I will just acknowledge a priori in the production run that these warnings are acceptable (for this purpose).

 

Thanks,

 

Kevin

Astounding
PROC Star

Given your answer, I'm not sure if this will be useful or not.  But here's a way to skip PROC CONTENTS when there are 0 observations (regardless of the number of variables).

 

data _null_;

set &whatever;

call execute ("proc contents data=&whatever; run;");

stop;

run;

 

 Also note, if this is your idea of fun, you can create a data set with multiple observations and zero variables:

 

data test;

do i=1 to 10;

   output;

end;

drop i;

run;

kmanderson
Calcite | Level 5
I had a similar problem with the NOWARN option. After several guesses at the correct syntax, the following worked: ODS OUTPUT TABLE (NOWARN) = LIB.DATASET;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2689 views
  • 1 like
  • 3 in conversation