<?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: IF data set exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774847#M246302</link>
    <description>&lt;P&gt;At &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote, see the log. And probably, the best way to see the reason why it "works as coded" would be to run it in a new fresh SAS session:&lt;/P&gt;
&lt;PRE&gt;1
2
3    /***Way2***/
4    %MACRO if_exists_b;
5    %if %sysfunc(exist(QQQ)) %then %do;
6    QQQ;
7    %end;
8    %MEND;
9    Data wanted;
10   set %if_exists_b;
ERROR: There is not a default input data set (_LAST_ is _NULL_).
11   Run;
&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Mon, 18 Oct 2021 09:41:12 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2021-10-18T09:41:12Z</dc:date>
    <item>
      <title>IF data set exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774810#M246280</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;Data set QQQ doesn't exist.&lt;/P&gt;
&lt;P&gt;Why the following 2 codes give different results.&lt;/P&gt;
&lt;P&gt;In way1 nothing happened (It is correct because data set QQQ doesnt exists)&lt;/P&gt;
&lt;P&gt;In way2 a data set wanted is created with following information&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ronein_0-1634538266495.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64808i69F83C6D91CD2BBC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ronein_0-1634538266495.png" alt="Ronein_0-1634538266495.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/****Way1***/
%MACRO if_exists_a;
%if %sysfunc(exist(QQQ)) %then %do;
Data wanted;
SET QQQ;
Run;
%end; 
%MEND;
%if_exists_a;


/***Way2***/
%MACRO if_exists_b;
%if %sysfunc(exist(QQQ)) %then %do;
QQQ;
%end; 
%MEND;
Data wanted;
set %if_exists_b;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Oct 2021 06:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774810#M246280</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-10-18T06:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: IF data set exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774812#M246282</link>
      <description>&lt;P&gt;In way 2, the data step will &lt;U&gt;always&lt;/U&gt; run and create an empty dataset if QQQ is not there.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 06:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774812#M246282</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-18T06:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: IF data set exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774813#M246283</link>
      <description>&lt;P&gt;As usual, the answer is in the log.&lt;/P&gt;
&lt;P&gt;Have you looked?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 06:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774813#M246283</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-10-18T06:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: IF data set exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774847#M246302</link>
      <description>&lt;P&gt;At &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;wrote, see the log. And probably, the best way to see the reason why it "works as coded" would be to run it in a new fresh SAS session:&lt;/P&gt;
&lt;PRE&gt;1
2
3    /***Way2***/
4    %MACRO if_exists_b;
5    %if %sysfunc(exist(QQQ)) %then %do;
6    QQQ;
7    %end;
8    %MEND;
9    Data wanted;
10   set %if_exists_b;
ERROR: There is not a default input data set (_LAST_ is _NULL_).
11   Run;
&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 09:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-data-set-exists/m-p/774847#M246302</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-10-18T09:41:12Z</dc:date>
    </item>
  </channel>
</rss>

