BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SBRVamsi
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
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;

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Ksharp
Super User

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_null__
Jade | Level 19
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;
ArtC
Rhodochrosite | Level 12

@data_null__I especially like your use of the $VARYING. format to essentially conditionally execute the LINE statement.

data_null__
Jade | Level 19

@ArtC I think it is worth mentioning this Usage Note: http://support.sas.com/kb/37/763.html

ArtC
Rhodochrosite | Level 12

Thank you @data_null__I do so love to learn, of course remembering is even better (and all too often the real challenge) Smiley Happy .

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 20889 views
  • 7 likes
  • 5 in conversation