how can i get only headers without any data when i write a proc report.
This will be help for me when there is no data in the dataset
Thanks
Vamsi.
data class;
stop;
set sashelp.class;
run;
*if class has 0 obs add 1 with missing values for all variables;
*if class has obs this does nothing;
data class;
if eof then output;
stop;
modify class end=eof;
run;
options missing=' ';
proc report data=class missing;
columns _all_;
define _all_ / display;
define name / order;
compute before name;
holdname=name;
endcomp;
compute after;
if missing(holdname) then l=40; else l=0;
msg = 'No data to report';
line msg $varying40. l;
endcomp;
run;
You can't directly. Output is only generated when there is data. Now you could do one of two things:
Insert a record into the empty dataset which states "No data to report" or something similar - this is what I tend to do, seen it many times across my field, as its clear then that there is no data to report.
The other alternative is to put some default value/text into the dataset, and when you report it, set the font color to be the same as the background color, hence hiding the text, you will just see an empty report - however not recommended as this could also occur if page breaks are messed up or some other problem happens, so its not clear to the reviewer.
The only thing I can think is making a table contain these variables name.
proc transpose data=sashelp.class(obs=0) out=class;
var _all_;
run;
proc transpose data=class out=want(drop=_name_ _label_);
var _name_;
run;
proc report data=want noheader nowd;run;
data class;
stop;
set sashelp.class;
run;
*if class has 0 obs add 1 with missing values for all variables;
*if class has obs this does nothing;
data class;
if eof then output;
stop;
modify class end=eof;
run;
options missing=' ';
proc report data=class missing;
columns _all_;
define _all_ / display;
define name / order;
compute before name;
holdname=name;
endcomp;
compute after;
if missing(holdname) then l=40; else l=0;
msg = 'No data to report';
line msg $varying40. l;
endcomp;
run;
@data_null__I especially like your use of the $VARYING. format to essentially conditionally execute the LINE statement.
@ArtC I think it is worth mentioning this Usage Note: http://support.sas.com/kb/37/763.html
Thank you @data_null__I do so love to learn, of course remembering is even better (and all too often the real challenge) .
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.