<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run Proc Report only if there are observations in a data set in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Run-Proc-Report-only-if-there-are-observations-in-a-data-set/m-p/272849#M15939</link>
    <description>&lt;P&gt;I guess you want something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doTestDataSet;
PROC SQL NOPRINT;
SELECT NOBS INTO :Nbr_Obs 
FROM DICTIONARY.TABLES
WHERE LIBNAME= 'work' AND MEMNAME= 'testdataset '
;
QUIT;

%if &amp;amp;Nbr_Obs &amp;gt; 0 %then %do;
    DATA NoObs; 
    testcolumnname = "No Data Today";
    RUN;

    PROC REPORT DATA=NoObs;
    COLUMN status;
    DEFINE status / center;
    RUN;
%end;
%else %do;
    proc report data=testdataset;
    ... whatever ...
    run;
%end;
%mend;

%doTestDataSet;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 24 May 2016 19:02:43 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-05-24T19:02:43Z</dc:date>
    <item>
      <title>Run Proc Report only if there are observations in a data set</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Run-Proc-Report-only-if-there-are-observations-in-a-data-set/m-p/272760#M15938</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some code I have found that will generate in a report if there are no observations in a data set.&amp;nbsp; The problem is that this still generates above the report even if there are observations.&amp;nbsp; I would like this to only run if there are no observations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL NOPRINT;
SELECT NOBS INTO :Nbr_Obs 
FROM DICTIONARY.TABLES
WHERE LIBNAME= 'work' AND MEMNAME= 'testdataset '
;
QUIT;

DATA NoObs; 
testcolumnname = "No Data Today";
RUN;

PROC REPORT DATA=NoObs;
COLUMN status;
DEFINE status / center;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If there are observations, I don't want DATA NoObs or PROC REPORT to RUN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried playing around with IF statments with no luck.&amp;nbsp; To provide a little color, this is custom code I am adding to an Enterprise Guide Script instide a List Data task that generates the report.&amp;nbsp; I don't think that is necessarily relevant as long as the code I am inserting is right.&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 15:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Run-Proc-Report-only-if-there-are-observations-in-a-data-set/m-p/272760#M15938</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-05-24T15:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Run Proc Report only if there are observations in a data set</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Run-Proc-Report-only-if-there-are-observations-in-a-data-set/m-p/272849#M15939</link>
      <description>&lt;P&gt;I guess you want something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro doTestDataSet;
PROC SQL NOPRINT;
SELECT NOBS INTO :Nbr_Obs 
FROM DICTIONARY.TABLES
WHERE LIBNAME= 'work' AND MEMNAME= 'testdataset '
;
QUIT;

%if &amp;amp;Nbr_Obs &amp;gt; 0 %then %do;
    DATA NoObs; 
    testcolumnname = "No Data Today";
    RUN;

    PROC REPORT DATA=NoObs;
    COLUMN status;
    DEFINE status / center;
    RUN;
%end;
%else %do;
    proc report data=testdataset;
    ... whatever ...
    run;
%end;
%mend;

%doTestDataSet;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2016 19:02:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Run-Proc-Report-only-if-there-are-observations-in-a-data-set/m-p/272849#M15939</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-24T19:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Run Proc Report only if there are observations in a data set</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Run-Proc-Report-only-if-there-are-observations-in-a-data-set/m-p/272881#M15942</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats﻿&lt;/a&gt; This worked perfectly.&amp;nbsp; Thanks so much!&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 20:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Run-Proc-Report-only-if-there-are-observations-in-a-data-set/m-p/272881#M15942</guid>
      <dc:creator>elwayfan446</dc:creator>
      <dc:date>2016-05-24T20:29:29Z</dc:date>
    </item>
  </channel>
</rss>

