<?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: selection if and output condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882782#M348785</link>
    <description>&lt;P&gt;Let's ignore the unmatched quotes and just look at the SUBSETTING IF statement you asked about.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if date_card_opened&amp;lt;="&amp;amp;sampedate"D; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the condition is TRUE then this iteration of the data step continues and the following commands are evaluated.&amp;nbsp; At the end of the data step iteration an observation is written (when there is no explicit OUTPUT statement in the data step).&lt;/P&gt;
&lt;P&gt;If the condition is FALSE then the iteration stops immediate and starts another iteration without executing the implied output. Since the first statement is the SET statement another observation is read in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could think of a statement like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (condition) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As doing the same thing as&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not (condition) then delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2023 12:26:10 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-06-28T12:26:10Z</dc:date>
    <item>
      <title>selection if and output condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882752#M348766</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data def_case;
set cca;
default=0;
bad_status='';
if block_code_1 ne '' and date_block_code_1&amp;gt;"&amp;amp;samoedate"d then block_code=";
if date_card_opened&amp;lt;="&amp;amp;sampedate"D;&amp;nbsp;
if block_code_1='A' and date_block_code_1&amp;lt;="&amp;amp;SAMPDATE"d then do;
ind_default=1;
bad_status='CHARGEOFF';
end;
ELSE IF refinance_acct ne "" and refINANCE_dATE&amp;lt;="&amp;amp;sampDATE"D THEN DO;
ind_default=1;
bad_status='REFINANCE_OLD";
end;

if product_code in ('CC") ad sme=0 and refion ne 'MAC" and inf_default=1 then output;
keep account_no
relationship_no
IND_CENTRAL_LIMIT
;
run;



&lt;/PRE&gt;
&lt;P&gt;in the above, does it mean the following:&lt;/P&gt;
&lt;P&gt;the line 'if DATE_CARD_OPENED &amp;lt;="&amp;amp;SAMPDATE"D' is a selection if i.e. only rows from cca satisfying this condition would have transformation above or below this condition applied to them;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then after all transforation is done&amp;nbsp;&lt;/P&gt;
&lt;P&gt;at the end we only output to data set def_case_CO_RE when a row satisfied the condition&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'if product_code in ("CC") and sme=0 and region ne 'MAC" and ind_default=1;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 08:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882752#M348766</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-06-28T08:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: selection if and output condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882756#M348769</link>
      <description>&lt;P&gt;You can run the code and see what it does.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 09:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882756#M348769</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-06-28T09:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: selection if and output condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882760#M348772</link>
      <description>I doubt the code you posted has ever worked. There are too many syntax errors. Please contact the person who wrote the code and ask him/her/they to explain. If that is not an option and you have the cca dataset you can run the code and try to correct the errors and then you should be able to draw conclusions.</description>
      <pubDate>Wed, 28 Jun 2023 09:47:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882760#M348772</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2023-06-28T09:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: selection if and output condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882782#M348785</link>
      <description>&lt;P&gt;Let's ignore the unmatched quotes and just look at the SUBSETTING IF statement you asked about.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if date_card_opened&amp;lt;="&amp;amp;sampedate"D; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the condition is TRUE then this iteration of the data step continues and the following commands are evaluated.&amp;nbsp; At the end of the data step iteration an observation is written (when there is no explicit OUTPUT statement in the data step).&lt;/P&gt;
&lt;P&gt;If the condition is FALSE then the iteration stops immediate and starts another iteration without executing the implied output. Since the first statement is the SET statement another observation is read in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could think of a statement like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (condition) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As doing the same thing as&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not (condition) then delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 12:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882782#M348785</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-28T12:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: selection if and output condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882875#M348836</link>
      <description>&lt;P&gt;What about lines above the condition; do they get run regardless of the condition?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 23:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882875#M348836</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-06-28T23:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: selection if and output condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882882#M348841</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; The "executable" statements in a data step are executed in the order they appear.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Non-executable statements are things like LABEL, LENGTH, FORMAT, ARRAY etc that just setup the structure of the data step but do not need to perform any action while the data step is running.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 01:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/selection-if-and-output-condition/m-p/882882#M348841</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-29T01:22:21Z</dc:date>
    </item>
  </channel>
</rss>

