<?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: Problems checking dataset if observations exist. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249474#M46930</link>
    <description>&lt;P&gt;I am SO sorry for not seeing this!&amp;nbsp; Just kinda of overwhelmed right now with so many things on my plate. I'm sure you know how that feels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for your assistance.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Feb 2016 16:20:59 GMT</pubDate>
    <dc:creator>ncsthbell</dc:creator>
    <dc:date>2016-02-11T16:20:59Z</dc:date>
    <item>
      <title>Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249459#M46925</link>
      <description>&lt;P&gt;I am using the following to read a&amp;nbsp;work dataset that was created right before the data_null step to check to see if any observations exists. When I added the code to my program it turns the next CREATE TABLE' statement red and gives errors.&lt;/P&gt;
&lt;P&gt;I cannot figure out what have have wrong with my data step.&amp;nbsp; Any help would be appreciated.&lt;/P&gt;
&lt;PRE&gt;data _null_;
 call symput('AnyObs','0'); /* set to 0 for No */
 set Work.Finacial_CORP(obs=1);
 call symput('AnyObs','1'); /* if got here there are obs so set to 1 for Yes */
run;

CREATE TABLE work.Financial_FRAN AS
   SELECT DISTINCT
          t1.DISTRICT, 
          t1.ACCOUNT_TYPE,
          t1.ACCOUNT_BEG_DATE, 
          t1.ACCOUNT_END_DATE, 
          t1.COUNTY_NAME, 
          t1.ADDR_LINE_1, 
	     t1.ADDR_LINE_2,
          t1.CITY, 
          t1.STATE, 
          t1.ZIP, 
	      count(*) FORMAT=comma7. AS FRANRptCnt
      FROM WORK.DATA_SELECTED t1
      WHERE t1.ACCOUNT_TYPE = 999;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 15:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249459#M46925</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-02-11T15:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249462#M46926</link>
      <description>&lt;P&gt;Where did your PROC SQL go?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need a PROC SQL; before your CREATE TABLE statement and a QUIT; at the end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE work.Financial_FRAN AS
   SELECT DISTINCT
          t1.DISTRICT, 
          t1.ACCOUNT_TYPE,
          t1.ACCOUNT_BEG_DATE, 
          t1.ACCOUNT_END_DATE, 
          t1.COUNTY_NAME, 
          t1.ADDR_LINE_1, 
	     t1.ADDR_LINE_2,
          t1.CITY, 
          t1.STATE, 
          t1.ZIP, 
	      count(*) FORMAT=comma7. AS FRANRptCnt
      FROM WORK.DATA_SELECTED t1
      WHERE t1.ACCOUNT_TYPE = 999;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 16:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249462#M46926</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-11T16:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249469#M46927</link>
      <description>&lt;P&gt;In creating multiple tables and I put the 'PROC SQL'&amp;nbsp; statement at the beginning of creating all the tables and the 'QUIT' at the end.&amp;nbsp; I changed it to put the PROC SQL and QUIT statements around each CREATE TABLE statement and that worked, however I got an error&lt;/P&gt;
&lt;P&gt;stating that my work dataset does not exist.&amp;nbsp;In the log it shows that it was created.&amp;nbsp; &amp;nbsp; I do notice that it seems to be looking for the same dataset name but with a '.DATA' on the end.&amp;nbsp; Here is the message....&lt;/P&gt;
&lt;PRE&gt;174                  t1.CORP_CD401S_TC22,
175        	      count(*) FORMAT=comma7. AS CORPRptCnt
176              FROM WORK.DATA_SELECTED t1
177              WHERE t1.ACCOUNT_TYPE = 250;
NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.FINANCIAL_CORP created, with 3 rows and 34 columns.

178        quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds
      

179        
180        /*Check if data set has data and set variable as a flag to*/
181        /*  trigger the CORP report(tab) to be created. */
182        data _null_;
183         call symput('AnyObs','0'); /* set to 0 for No */
184         set Work.Finacial_CORP(obs=1);
ERROR: File WORK.FINACIAL_CORP.DATA does not exist.
185         call symput('AnyObs','1'); /* if got here there are obs so set to 1 for Yes */
186        run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 16:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249469#M46927</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-02-11T16:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249471#M46928</link>
      <description>&lt;P&gt;typo....&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Table WORK.&lt;STRONG&gt;FINA&lt;FONT color="#FF0000"&gt;N&lt;/FONT&gt;CIAL_CORP&lt;/STRONG&gt; created, with 3 rows and 34 columns.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Missing an N here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: File WORK.&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;FINACIAL_CORP&lt;/STRONG&gt;&lt;/FONT&gt;.DATA does not exist.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 16:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249471#M46928</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-11T16:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249472#M46929</link>
      <description>&lt;P&gt;typo....&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Table WORK.&lt;STRONG&gt;FINA&lt;FONT color="#FF0000"&gt;N&lt;/FONT&gt;CIAL_CORP&lt;/STRONG&gt; created, with 3 rows and 34 columns.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Missing an N here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: File WORK.&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;FINACIAL_CORP&lt;/STRONG&gt;&lt;/FONT&gt;.DATA does not exist.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 16:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249472#M46929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-11T16:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249474#M46930</link>
      <description>&lt;P&gt;I am SO sorry for not seeing this!&amp;nbsp; Just kinda of overwhelmed right now with so many things on my plate. I'm sure you know how that feels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much for your assistance.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 16:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249474#M46930</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-02-11T16:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249484#M46932</link>
      <description>&lt;P&gt;I am still not getting the results that I want in the step to check for observations in the dataset.&amp;nbsp;&amp;nbsp; The data set is created with 3 rows, however, after running the data code to check the obervastions in the dataset, it returns the value of '0' which indicates no rows.&lt;/P&gt;
&lt;P&gt;I have never used this before and don't know what I have wrong in the data step.&amp;nbsp; All I need to know is if there is data or not and the '0' means no data.&amp;nbsp; Is this the best way to check?&amp;nbsp;The Work.Financial_CORP datasest shows it has 3 rows. I used a put statement to display the value of CORPobs and it is showing value of 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the displayed results from log:&lt;/P&gt;
&lt;PRE&gt;NOTE: The query requires remerging summary statistics back with the original data.
NOTE: Table WORK.FINANCIAL_CORP created, with 3 rows and 35 columns.

180        quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
      

181        
182        /*Check if data set has data and set variable as a flag to*/
183        /*  trigger the CORP report(tab) to be created. */
184        data _null_;
185         call symput('CorpObs','0'); /* set to 0 for No */
186         set Work.Financial_CORP(obs=1);
187         call symput('CorpObs','1'); /* if got here there are obs so set to 1 for Yes */
188        run;

NOTE: There were 1 observations read from the data set WORK.FINANCIAL_CORP.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

189        %put &amp;amp;CorpObs;
0&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 16:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249484#M46932</guid>
      <dc:creator>ncsthbell</dc:creator>
      <dc:date>2016-02-11T16:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249487#M46933</link>
      <description>&lt;P&gt;There's a lot of papers written on this, no need to reinvent the wheel. I am curious as to why the macro variable does resolve to 0 though.&lt;/P&gt;
&lt;P&gt;At any rate, after thinking about this, I don't think this is a good method, because you'll get an error in your log if it's 0 and that's not a good way to test something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Google on Lexjansen.com -&amp;gt; Check if sas dataset is empty&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://analytics.ncsu.edu/sesug/2011/CC19.Childress.pdf" target="_blank"&gt;http://analytics.ncsu.edu/sesug/2011/CC19.Childress.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 17:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249487#M46933</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-11T17:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problems checking dataset if observations exist.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249500#M46942</link>
      <description>&lt;P&gt;Save some headaches: When you run Proc Sql to create a table SAS sets the value of an automatic variable &amp;amp;sqlobs to the number of records returned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So IMMEDIATELY after the SQL step add something like&lt;/P&gt;
&lt;P&gt;%let CorpObs = %eval(&amp;amp;sqlobs &amp;gt; 0);&lt;/P&gt;
&lt;P&gt;to get a 1 / 0 value for CorpObs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 17:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problems-checking-dataset-if-observations-exist/m-p/249500#M46942</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-11T17:57:57Z</dc:date>
    </item>
  </channel>
</rss>

