<?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 SAS QUERY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-QUERY/m-p/349056#M80921</link>
    <description>&lt;P&gt;DATA TEST201704;&lt;BR /&gt;INPUT ID $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;110&lt;BR /&gt;111&lt;BR /&gt;112&lt;BR /&gt;113&lt;BR /&gt;114&lt;BR /&gt;115&lt;BR /&gt;116&lt;BR /&gt;117&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;DATA TEST201703;&lt;BR /&gt;INPUT ID $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;110&lt;BR /&gt;111&lt;BR /&gt;112&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE TESTING AS SELECT *,&lt;BR /&gt;CASE WHEN ID IN (SELECT ID FROM TEST201703) THEN 0 ELSE 1 END AS EXIST&lt;BR /&gt;FROM TEST201704;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above proc sql codes is working fine.&amp;nbsp; As the TEST dataset is not available in every period, it could have no data on some period, e.g. 201702.&amp;nbsp; if I run the below codes, there will be an error message read "ERROR: File WORK.TEST201702.DATA does not exist."&lt;/P&gt;&lt;P&gt;My question is: May i know how to set the EXIST key to 1 in TESTING data if the previous period of TEST data (TEST201702) not available? Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE TESTING AS SELECT *,&lt;BR /&gt;CASE WHEN ID IN (SELECT ID FROM TEST201702) THEN 0 ELSE 1 END AS EXIST&lt;BR /&gt;FROM TEST201703;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Apr 2017 11:08:32 GMT</pubDate>
    <dc:creator>scb</dc:creator>
    <dc:date>2017-04-11T11:08:32Z</dc:date>
    <item>
      <title>SAS QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-QUERY/m-p/349056#M80921</link>
      <description>&lt;P&gt;DATA TEST201704;&lt;BR /&gt;INPUT ID $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;110&lt;BR /&gt;111&lt;BR /&gt;112&lt;BR /&gt;113&lt;BR /&gt;114&lt;BR /&gt;115&lt;BR /&gt;116&lt;BR /&gt;117&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;DATA TEST201703;&lt;BR /&gt;INPUT ID $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;110&lt;BR /&gt;111&lt;BR /&gt;112&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE TESTING AS SELECT *,&lt;BR /&gt;CASE WHEN ID IN (SELECT ID FROM TEST201703) THEN 0 ELSE 1 END AS EXIST&lt;BR /&gt;FROM TEST201704;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above proc sql codes is working fine.&amp;nbsp; As the TEST dataset is not available in every period, it could have no data on some period, e.g. 201702.&amp;nbsp; if I run the below codes, there will be an error message read "ERROR: File WORK.TEST201702.DATA does not exist."&lt;/P&gt;&lt;P&gt;My question is: May i know how to set the EXIST key to 1 in TESTING data if the previous period of TEST data (TEST201702) not available? Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE TESTING AS SELECT *,&lt;BR /&gt;CASE WHEN ID IN (SELECT ID FROM TEST201702) THEN 0 ELSE 1 END AS EXIST&lt;BR /&gt;FROM TEST201703;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 11:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-QUERY/m-p/349056#M80921</guid>
      <dc:creator>scb</dc:creator>
      <dc:date>2017-04-11T11:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAS QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-QUERY/m-p/349062#M80925</link>
      <description>&lt;P&gt;You need first to check if the dataset exists and then branch to different code logic based on existence or not.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/24/670.html&amp;nbsp;" target="_blank"&gt;http://support.sas.com/kb/24/670.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way to go could be that you create an empty dataset in case it doesn't exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 11:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-QUERY/m-p/349062#M80925</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-04-11T11:43:59Z</dc:date>
    </item>
  </channel>
</rss>

