Desktop productivity for business analysts and programmers

Need "List Data" output when Obs=0

Reply
Valued Guide
Posts: 2,111

Need "List Data" output when Obs=0

Hi,

I am doing some ETL and am writing monthly reports on inconsistent data in some data files I receive.  The reports are being send out as e-mail as a step in the project.  If the data are perfect, there is nothing to list.  Currently the list task does not generate any output (using ODS to RTF file).  That BREAKS the link to the e-mail.  Which would be OK, until the next month when there might be bad data again.  I am using EG 5.1 and SAS 9.3.

Is there some option for the task or project that would force it to print?

I think that I could use %sysnobs to write some macro code to force printing, but I has hoping for something less klugy.

Thanks,

Doc Muhlbaier

Duke

Respected Advisor
Posts: 2,655

Re: Need "List Data" output when Obs=0

Doc,

Suppose the emailed file is baddata.sas7bdat.  Could you append it to a dataset that had only the current date as a record, and then send the concatenated set?  That way there would always be something in the concatenated set, the email would be sent, plus the first record would always be the date of creation.

Steve Denham

Respected Advisor
Posts: 4,985

Re: Need "List Data" output when Obs=0

If you are using PUT statements to generate the contents of the email, the same DATA step could easily perform the needed tasks ...

Find the number of observations in the exceptions data.

Use an IF/THEN statement to write an appropriate message when there are 0 observations.

Super Contributor
Posts: 358

Re: Need "List Data" output when Obs=0

You can count the records in the data set using a SQL:

PROC SQL;

CREATE TABLE WANT AS

SELECT COUNT(*) AS COUNTER

FROM source.table;

QUIT;

RUN;

This will set variable &SQLOBS to the number of rows the SQL processed.

You then query this value in a DATA step and perform action - if zero to something, else print report.

Ask a Question
Discussion stats
  • 3 replies
  • 160 views
  • 0 likes
  • 4 in conversation