<?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: Multiple then from single if condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888393#M351002</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/443657"&gt;@TB10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp; i tried this but i am unable to check the values of a and b when i write put a; put b; out side of the loop. Anyway to check the values. As mentioned i am unable to access the variable values outside the loop.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if flag=1 then do;
    a =intnx('day',today(),-1);
    b=intnx('day',today(),-2);
    put a= b=;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 08 Aug 2023 14:47:13 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-08-08T14:47:13Z</dc:date>
    <item>
      <title>Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888372#M350992</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338236"&gt;@fja&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i have a scenario as follows:&lt;/P&gt;&lt;P&gt;a =intnx('day',today(),-1);&lt;/P&gt;&lt;P&gt;b=intnx('day',today(),-2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;we have a variable named flag whose value is set based on other conditions.&lt;/P&gt;&lt;P&gt;now what is desired is: suppose flag=1:&lt;/P&gt;&lt;P&gt;if flag=1 then&amp;nbsp;a =intnx('day',today(),-1) and&amp;nbsp;b=intnx('day',today(),-2);&lt;/P&gt;&lt;P&gt;so the above syntax is desired but looks like we cannot add multiple then conditions through and.&lt;/P&gt;&lt;P&gt;i tried with if..do statements but after we end the statement i cannot access the variable a &amp;amp; b after that. can you please help me here.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888372#M350992</guid>
      <dc:creator>TB10</dc:creator>
      <dc:date>2023-08-08T14:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888373#M350993</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;if flag=1 then&amp;nbsp;a =intnx('day',today(),-1) and&amp;nbsp;b=intnx('day',today(),-2);&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if flag=1 then do;
    a =intnx('day',today(),-1);
    b=intnx('day',today(),-2);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888373#M350993</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-08T14:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888374#M350994</link>
      <description>&lt;P&gt;Please show the code you tried, along with some test data.&amp;nbsp; Using IF THEN DO should work, like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if flag=1 then do;
  a=intnx('day',today(),-1);
  b=intnx('day',today(),-2);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888374#M350994</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-08-08T14:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888380#M350996</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp; i tried this but i am unable to check the values of a and b when i write put a; put b; out side of the loop. Anyway to check the values. As mentioned i am unable to access the variable values outside the loop.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888380#M350996</guid>
      <dc:creator>TB10</dc:creator>
      <dc:date>2023-08-08T14:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888382#M350997</link>
      <description>&lt;P&gt;Again, please show your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;
  if flag=1 then do;
    a=intnx('day',today(),-1);
    b=intnx('day',today(),-2);
  end;
  put a= b=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Check your log for error messages/warnings/bad notes.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888382#M350997</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-08-08T14:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888384#M350999</link>
      <description>&lt;P&gt;ADD is a logical operator.&amp;nbsp; So unless variable B already has the date that is TODAY()-2 then this statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;a =intnx('day',today(),-1) and b=intnx('day',today(),-2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will set A to zero.&amp;nbsp; The first expression&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;intnx('day',today(),-1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which can more easily be written as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(today()-1)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is only false if today is 02JAN1960.&lt;/P&gt;
&lt;P&gt;But the second condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;b=(today()-2)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can only be true if the variable B already has a value that is the number used by SAS to present the day before yesterday.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to execute the DO statement in the IF/THEN statement.&amp;nbsp; This will allow you execute multiple statements when the IF condition is satisfied.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if flag=1 then do;
  a =today()-1;
  b = a-1;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888384#M350999</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-08T14:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888393#M351002</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/443657"&gt;@TB10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp; i tried this but i am unable to check the values of a and b when i write put a; put b; out side of the loop. Anyway to check the values. As mentioned i am unable to access the variable values outside the loop.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if flag=1 then do;
    a =intnx('day',today(),-1);
    b=intnx('day',today(),-2);
    put a= b=;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888393#M351002</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-08T14:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple then from single if condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888408#M351006</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/443657"&gt;@TB10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp; i tried this but i am unable to check the values of a and b when i write put a; put b; out side of the loop. Anyway to check the values. As mentioned i am unable to access the variable values outside the loop.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps you intended the values of A and B to be retained across iterations (in a simple data step that is the same as across observations) of the data step.&amp;nbsp; Add a RETAIN statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;retain A B ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You also need to have a FORMAT statement so the date values will print in a human recognizable style.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format A B yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 15:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-then-from-single-if-condition/m-p/888408#M351006</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-08T15:19:39Z</dc:date>
    </item>
  </channel>
</rss>

