<?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 why 'if 0 then set' still copy an empty record? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57847#M12542</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Data step user&lt;/P&gt;&lt;P&gt;data b;&lt;/P&gt;&lt;P&gt;if 0 then set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print ;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since it is never actually executed, why there is still an empty record been created?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 07 Apr 2012 03:34:50 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-04-07T03:34:50Z</dc:date>
    <item>
      <title>why 'if 0 then set' still copy an empty record?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57847#M12542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Data step user&lt;/P&gt;&lt;P&gt;data b;&lt;/P&gt;&lt;P&gt;if 0 then set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print ;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;since it is never actually executed, why there is still an empty record been created?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Apr 2012 03:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57847#M12542</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-04-07T03:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: why 'if 0 then set' still copy an empty record?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57848#M12543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A nice explanation of what occurs when can be found in the following paper: &lt;A class="jive-link-external-small" href="http://www.lexjansen.com/nesug/nesug88/sas_supervisor.pdf" style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3778c7; background-color: #ffffff;"&gt;http://www.lexjansen.com/nesug/nesug88/sas_supervisor.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The pdv is populated first, thus the five variables exist.&amp;nbsp; One loop was completed, thus one record has to be output.&amp;nbsp; If you want to do something similar, but not have any loop occur, you could run:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data b;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; if 0;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;That way, you will still get 5 variables, but 0 records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Apr 2012 04:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57848#M12543</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-04-07T04:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: why 'if 0 then set' still copy an empty record?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57849#M12544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Art. That was indeed great paper, I have come across it long before I know anything about pdv, and of course I failed to register. Now everything makes sense, Yeah!&lt;/P&gt;&lt;P&gt;BTW, It has also been known to me that if just wanting the structure, (obs=0) will do, too. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Apr 2012 12:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57849#M12544</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-04-07T12:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: why 'if 0 then set' still copy an empty record?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57850#M12545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You end up with one record because the data step has looped once and output one record.&lt;/P&gt;&lt;P&gt;See how many records you get with the trivial step.&amp;nbsp; data a; run;&lt;/P&gt;&lt;P&gt;To get 0 records you will need to do something to stop it from outputting the record.&lt;/P&gt;&lt;P&gt;Here are some ways:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data b; set sashelp.class(obs=0); run;&lt;/P&gt;&lt;P&gt;data b; if 0 then set sashelp.class; stop; run;&lt;/P&gt;&lt;P&gt;data b; set sashelp.class; if 0 then output; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Apr 2012 14:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57850#M12545</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-07T14:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: why 'if 0 then set' still copy an empty record?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57851#M12546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Tom. Your examples are very helpful! I especially like the third one: if 0 then output. really wicked me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Apr 2012 19:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-if-0-then-set-still-copy-an-empty-record/m-p/57851#M12546</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-04-07T19:47:18Z</dc:date>
    </item>
  </channel>
</rss>

