10-04-2016 11:08 AM
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 ;
How can I avoid the output variables not created warning? I have tried variations on:
ods output variables = variables ( nowarn ) ;
10-04-2016 11:18 AM
Sometimes you'll see a hybrid like this:
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?
10-04-2016 01:46 PM
Correct, as does my preferred flavor:
data want ;
if 0 then set have ;
(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
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).
10-04-2016 01:57 PM - edited 10-04-2016 02:00 PM
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).
call execute ("proc contents data=&whatever; run;");
Also note, if this is your idea of fun, you can create a data set with multiple observations and zero variables:
do i=1 to 10;