<?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 IF statement execution in PDV in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394542#M95096</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code to see how IF statement executes in PDV. It, however, just shows the reading in the observations from input data set. How to see the action of IF statement in PDV?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   put _all_;
   set sashelp.class;
   put _all_;
   if age &amp;gt; 14;
   put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Sep 2017 00:11:18 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2017-09-11T00:11:18Z</dc:date>
    <item>
      <title>IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394542#M95096</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following code to see how IF statement executes in PDV. It, however, just shows the reading in the observations from input data set. How to see the action of IF statement in PDV?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   put _all_;
   set sashelp.class;
   put _all_;
   if age &amp;gt; 14;
   put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Sep 2017 00:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394542#M95096</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-09-11T00:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394543#M95097</link>
      <description>&lt;P&gt;I'm not sure what it is you're expecting to see - the data set variables are read into the PDV along with any computed variables plus _n_ and _error_ and that's what you shopuld be seeing in your log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're not creating any computed variables in your IF statement so there's nothing to see - if you want to create a computed variable which isn't ultimately stored in the out data set then do this and you'll see the valu in your put _all_ statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test(drop=pdv_var);
   put _all_;
   set sashelp.class;
   put _all_;
   if age &amp;gt; 14 the pdv_var=99;
   put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Sep 2017 00:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394543#M95097</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-11T00:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394545#M95098</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32246"&gt;@ChrisBrooks&lt;/a&gt;&amp;nbsp;May be my question is not clear enough. I don't want to create new variable; but want to envision what might be goin on in PDV when IF statement executes. In general sense, we know it selects observations with AGE greater than 14.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 00:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394545#M95098</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-09-11T00:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394547#M95099</link>
      <description>&lt;P&gt;One clue you need to examine is the value of _N_. &amp;nbsp;Also keep in mind that variables read from a SET statement are automatically retained.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With that in mind, you should be able to see that all three PUT statements execute when AGE &amp;gt; 14.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, when AGE &amp;lt;= 14, the first two PUT statements execute, but the third one doesn't.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 01:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394547#M95099</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-11T01:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394548#M95100</link>
      <description>The subsetting IF executes AFTER the data has been read into the PDV so there's nothing to see.</description>
      <pubDate>Mon, 11 Sep 2017 01:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394548#M95100</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-11T01:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394549#M95101</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32246"&gt;@ChrisBrooks&lt;/a&gt;&amp;nbsp;said, the PDV and the IF statement are not linked.&lt;/P&gt;
&lt;P&gt;1 - Data is loaded in PDV&lt;/P&gt;
&lt;P&gt;2 - Data step statements are executed&lt;/P&gt;
&lt;P&gt;3- IF clause is read&lt;/P&gt;
&lt;P&gt;4- IF returns false, therefore the data step stops the iteration (and skips the implicit &lt;FONT face="courier new,courier"&gt;output&lt;/FONT&gt; statement at the end).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for your program, when you run it you can see that for example&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Name=Janet Sex=F Age=15&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;appears 3 times in the log&amp;nbsp;whereas&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Name=Jane Sex=F Age=12&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;only appears twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now with a where clause, the PDV is impacted.&lt;/P&gt;
&lt;P&gt;Not&amp;nbsp;with an IF statement.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 01:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/394549#M95101</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-09-11T01:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/551556#M153251</link>
      <description>Think of the PDV as an internal tracking or lookup table of system and data variables that you can query for info.</description>
      <pubDate>Tue, 16 Apr 2019 20:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/551556#M153251</guid>
      <dc:creator>CJac73</dc:creator>
      <dc:date>2019-04-16T20:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement execution in PDV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/551594#M153271</link>
      <description>&lt;P&gt;Your terminology is off. The Program Data Vector is just the place where SAS is storing the values for current iteration of the data step.&amp;nbsp; Think of it as containing all of the variables your program reads and/or creates and also all of the automatic variables (_n_, _error_ etc).&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 02:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statement-execution-in-PDV/m-p/551594#M153271</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-17T02:07:33Z</dc:date>
    </item>
  </channel>
</rss>

