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
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?
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
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.