BookmarkSubscribeRSS Feed
FrankE
Fluorite | Level 6
Hi all,

I'm using the excelXP tagset to create an Excel workbook with 2 tabs. Sometimes one of the datasets is empty and the tab is not produced at all. In the case of an empty dataset, I'd still like to produce the tab with just a header row so the user knows the report was run but found no records. Suggestions?
4 REPLIES 4
Peter_C
Rhodochrosite | Level 12
modify that empty dataset to have just one "missing" row, with something like this
- assuming the data set is named in &dataset and it is the kind of data set that will have a value for NOBS[pre]
data _null_ ;
if not nobs then
call execute( 'data &dataset; output ; set &dataset ; run ; ' ) ;
stop;
set &dataset nobs=nobs ;
run ;[/pre]seems to work for me

peterC
FrankE
Fluorite | Level 6
That worked perfectly! Thanks much!
data_null__
Jade | Level 19
This method that I thought I learned from you seems more concise. Plus it does not rely on NOBS.

data &dataset;
if _n_ eq 1 and eof then output;
stop;
modify &dataset end=eof;
run;
Peter_C
Rhodochrosite | Level 12
glad someone remembers 😉

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 862 views
  • 0 likes
  • 3 in conversation