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

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