<?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: Help with creating new variable with if-then statement  (sas 9.4) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-new-variable-with-if-then-statement-sas-9-4/m-p/930538#M366114</link>
    <description>&lt;P&gt;Below is untested, but why not change&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and LDOS lt Span_end_3 
and FDOS lt Span_end_3 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  and (span_end_3=. or LDOS lt Span_end_3 )
  and (span_end_3=. or FDOS lt Span_end_3 )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Editted note:&lt;/P&gt;
&lt;P&gt;If you have instances of both span_end_3 and LDOS (or FDOS) the above suggestion would still pass the IF test.&amp;nbsp; If you want such situations to fail the test, then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  and LDOS lt max(LDOS,Span_end_3)
  and FDOS lt max(FDOS,Span_end_3)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will force both LDOS (or FDOS) and span_end_3 to be non-missing as well as satisfy the desired inequality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 02 Jun 2024 13:59:51 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2024-06-02T13:59:51Z</dc:date>
    <item>
      <title>Help with creating new variable with if-then statement  (sas 9.4)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-new-variable-with-if-then-statement-sas-9-4/m-p/930535#M366112</link>
      <description>&lt;P&gt;I am trying to create a variable that will indicate if both LDOS and FDOS are :&lt;/P&gt;
&lt;P&gt;after span_end_2&lt;/P&gt;
&lt;P&gt;and before after_cutoff_2&lt;/P&gt;
&lt;P&gt;and before span_end_3.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue I have is that in most cases, span_end_3 is blank/.&amp;nbsp; in which case the current code I have below will treat LDOS and FDOS as &amp;gt;&amp;nbsp; span_end_3.&amp;nbsp; I need to fix my code so sas will treat LDOS and FDOS as &amp;lt; span_end_3 when span_end_3 is blank. Is there a way to do this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input
ID$	LDOS :DATE9.	FDOS :DATE9.	Span_Begin_1 :DATE9.	Span_End_1 :DATE9.	Span_Begin_2 :DATE9.
Span_End_2 :DATE9.	Span_Begin_3 :DATE9.	Span_End_3 :DATE9.	after_cutoff_2 :DATE9. ;

format FDOS MMDDYY10. LDOS MMDDYY10. Span_Begin_1 MMDDYY10. Span_End_1 MMDDYY10.  Span_Begin_2 MMDDYY10.
Span_End_2 MMDDYY10. Span_Begin_3  MMDDYY10. after_cutoff_2 MMDDYY10.;

datalines;

5	20Apr2023	20Apr2023	1Jul2022	    29Jul2022	21Nov2022	    4Apr2023	.	  .	    3Apr2024	
5	24Apr2023	24Apr2023	1Jul2022	    29Jul2022	21Nov2022    	4Apr2023	.	  .		3Apr2024	
5	25Apr2023	25Apr2023	1Jul2022	    29Jul2022	21Nov2022	    4Apr2023	.	  .		3Apr2024	
5	1May2023	1May2023	1Jul2022	    29Jul2022	21Nov2022    	4Apr2023	.	  .		3Apr2024	

;;;
run;

data want;
set have;

if LDOS gt Span_end_2 
and FDOS gt Span_end_2  
and LDOS lt after_cutoff_2
and FDOS lt after_cutoff_2 
and LDOS lt Span_end_3 
and FDOS lt Span_end_3 
then After_Span2=1;
else After_Span2=0;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2024 17:07:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-new-variable-with-if-then-statement-sas-9-4/m-p/930535#M366112</guid>
      <dc:creator>Whitlea</dc:creator>
      <dc:date>2024-06-01T17:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help with creating new variable with if-then statement  (sas 9.4)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-new-variable-with-if-then-statement-sas-9-4/m-p/930538#M366114</link>
      <description>&lt;P&gt;Below is untested, but why not change&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and LDOS lt Span_end_3 
and FDOS lt Span_end_3 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  and (span_end_3=. or LDOS lt Span_end_3 )
  and (span_end_3=. or FDOS lt Span_end_3 )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Editted note:&lt;/P&gt;
&lt;P&gt;If you have instances of both span_end_3 and LDOS (or FDOS) the above suggestion would still pass the IF test.&amp;nbsp; If you want such situations to fail the test, then use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  and LDOS lt max(LDOS,Span_end_3)
  and FDOS lt max(FDOS,Span_end_3)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will force both LDOS (or FDOS) and span_end_3 to be non-missing as well as satisfy the desired inequality.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2024 13:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-new-variable-with-if-then-statement-sas-9-4/m-p/930538#M366114</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-06-02T13:59:51Z</dc:date>
    </item>
  </channel>
</rss>

