<?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: strange code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847582#M335098</link>
    <description>So it is just creating an empty dataset?</description>
    <pubDate>Sat, 03 Dec 2022 16:56:15 GMT</pubDate>
    <dc:creator>HeatherNewton</dc:creator>
    <dc:date>2022-12-03T16:56:15Z</dc:date>
    <item>
      <title>strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847570#M335092</link>
      <description>&lt;PRE&gt;data _null_;
    if exist ('WDATA.TUEF_EA_H') then stop;
    else call execute ('proc sql; create table WDATA.TUEF_EA_H as select * from SDATA.TUEF_EA where 1=2;quit;');
run;&lt;/PRE&gt;
&lt;P&gt;in the above code, does it mean if it cannot find WDATA.TUEF_EA_H in folder WDATA, it will create one? What does 1=2 means?&lt;/P&gt;</description>
      <pubDate>Sat, 03 Dec 2022 13:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847570#M335092</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-12-03T13:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847572#M335093</link>
      <description>&lt;P&gt;Sometimes, all you have to do is look at the documentation. Here is the documentation for the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/p1thpm9d6f5itan1c37zh8uz273z.htm" target="_self"&gt;EXIST function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1 id="p1thpm9d6f5itan1c37zh8uz273z" class="xisDoc-title"&gt;EXIST Function&lt;/H1&gt;
&lt;P class="xisDoc-shortDescription"&gt;Verifies the existence of a SAS library member within a currently assigned SAS data library.&lt;/P&gt;
&lt;P class="xisDoc-shortDescription"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="xisDoc-shortDescription"&gt;In PROC SQL, you can refer to variables by their position in the SELECT clause. So 1=2 is testing to see if the first variable in the SELECT clause is equal to 2. In my opinion, this is really a poor way to program anything, unless your goal is to make the code as unreadable as possible. I would advise not doing this.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Dec 2022 13:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847572#M335093</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-03T13:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847578#M335095</link>
      <description>&lt;P&gt;Yes. 1=2 is an obviously FALSE condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure why the data step is generating SQL code.&amp;nbsp; The programmer obviously knows how to write data step code so why not generate a data step? It would be shorter and much less confusing than the SQL code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    if exist ('WDATA.TUEF_EA_H') then stop;
    else call execute ('data WDATA.TUEF_EA_H;set SDATA.TUEF_EA(obs=0);run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Dec 2022 16:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847578#M335095</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-03T16:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847582#M335098</link>
      <description>So it is just creating an empty dataset?</description>
      <pubDate>Sat, 03 Dec 2022 16:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847582#M335098</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-12-03T16:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847583#M335099</link>
      <description>What is more strange is the next bit&lt;BR /&gt;&lt;BR /&gt;Proc sql;&lt;BR /&gt;   Insert into wdata.tuef_ea_h&lt;BR /&gt;   Select * from sdata.tuef_ea:&lt;BR /&gt;quit;</description>
      <pubDate>Sat, 03 Dec 2022 16:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847583#M335099</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-12-03T16:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847584#M335100</link>
      <description>&lt;P&gt;So the combination to append from SDATA to WDATA.&lt;/P&gt;
&lt;P&gt;So if your version of SAS is recent enough (or the code is inside a macro) then you can just do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data wdata.tuef_ea_h;
  set
%if %sysfunc(exist(wdata.tuef_ea_h)) %then %do;
    wdata.tuef_ea_h
%end;
    sdata.tuef_ea&lt;BR /&gt;  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if&amp;nbsp;wdata.tuef_ea_h might get really large perhaps you want to do this to save some time.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(exist(wdata.tuef_ea_h)) %then %do;
  proc append base=wdata.tuef_ea_h data=sdata.tuef_ea;
  run;
%end;
%else do;
  data wdata.tuef_ea_h;
    set sdata.tuef_ea ;
  run;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Dec 2022 17:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847584#M335100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-03T17:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847613#M335111</link>
      <description>&lt;P&gt;Or just&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc append base=wdata.tuef_ea_h data=sdata.tuef_ea;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as PROC APPEND knows what to do if the BASE dataset does not exist:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#3366FF"&gt;NOTE: BASE data set does not exist. DATA file is being copied to BASE file.&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Dec 2022 23:11:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847613#M335111</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-12-03T23:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847614#M335112</link>
      <description>&lt;P&gt;This is a bit off-topic, but I hope your recent posts highlighting obscure coding practices provide a lesson to those coders who delight in doing this, often for no good reason.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your code is to be used and maintained by others, write it in such a way that they can easily understand it. Exhibit 1 has to be: &lt;STRONG&gt;where 1=2&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Dec 2022 23:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847614#M335112</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-12-03T23:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847652#M335124</link>
      <description>&lt;P&gt;I've seen WHERE 1=2 elsewhere.&amp;nbsp; Especially in languages, like SAS, which don't have a boolean variable type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS, I would probably do this as WHERE 0 ;&amp;nbsp; Curious if you would think WHERE 0 is obscure, or a reasonable pattern?&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2022 18:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847652#M335124</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-12-04T18:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: strange code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847659#M335127</link>
      <description>&lt;P&gt;I would also prefer WHERE 0, but not in this particular case, as the clean PROC SQL way to create an empty dataset&amp;nbsp;with the structure of another dataset&amp;nbsp;does not require &lt;EM&gt;any&lt;/EM&gt; WHERE condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table wdata.tuef_ea_h
like sdata.tuef_ea;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Dec 2022 19:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strange-code/m-p/847659#M335127</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-12-04T19:53:44Z</dc:date>
    </item>
  </channel>
</rss>

