<?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: If Then Else Statemen with date variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/841022#M36450</link>
    <description>Thank you!</description>
    <pubDate>Wed, 26 Oct 2022 20:21:20 GMT</pubDate>
    <dc:creator>Jesusismygrace</dc:creator>
    <dc:date>2022-10-26T20:21:20Z</dc:date>
    <item>
      <title>If Then Else Statemen with date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/840714#M36441</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a new variable that contains dates less than 9/1/2022; but for the life of me, I can not get the following statement to work. Thanks in advance for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Work.Quest_Results_2;&lt;BR /&gt;Set Work.Quest_Results_2;&lt;BR /&gt;term1 = input(terminationdate, mmddyy10.);&lt;BR /&gt;format term1 mmddyy10.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Data Work.Quest_Results_3;&lt;BR /&gt;set Work.Quest_Results_2;&lt;BR /&gt;if term1 le '01Sep2022'd then termed = term1;&lt;BR /&gt;else termed = "";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 22:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/840714#M36441</guid>
      <dc:creator>Jesusismygrace</dc:creator>
      <dc:date>2022-10-25T22:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: If Then Else Statemen with date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/840718#M36442</link>
      <description>&lt;P&gt;Is your Terminationdate variable text? If so, what does it look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is chance that this code:&lt;/P&gt;
&lt;PRE&gt;data Work.Quest_Results_2;
Set Work.Quest_Results_2;&lt;/PRE&gt;
&lt;P&gt;on a previous pass has corrupted or lost data. Using the same data set for input and output completely replaces the original data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your use of Termed is mixing numeric, the value of hopefully a date value in Term1 and character with e termed = ""; Assign missing values to numeric variable with&amp;nbsp; termed = . ; or just not even bother to execute the Else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does your log look like?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 22:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/840718#M36442</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-25T22:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: If Then Else Statemen with date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/840736#M36444</link>
      <description>&lt;P&gt;DATE values are numeric. So use a numeric missing value, not a character string.&amp;nbsp; Or use the CALL MISSING() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Work.Quest_Results_3;
  set Work.Quest_Results_2;
  term1 = input(terminationdate, mmddyy10.);
  termed = term1;
  if termed &amp;gt; '01SEP2022'd then call missing(termed);
  format term1 termed YYMMDD10. ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Are you trying to do a censored survival analysis?&lt;/P&gt;
&lt;P&gt;In that case it might be better to use a truncated date instead of setting the later dates to missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Work.Quest_Results_3;
  set Work.Quest_Results_2;
  term1 = input(terminationdate, mmddyy10.);
  censored = term1 &amp;gt; '01SEP2022'd ;
  termed = min(term1,'01SEP2022'd);
  format term1 termed YYMMDD10. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;PS&lt;/STRONG&gt; Displaying dates in MDY or DMY order will confuse 50% of your audience. Display them using YMD order or the DATE format to avoid confusing May First for the Fifth of January.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 02:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/840736#M36444</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-26T02:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: If Then Else Statemen with date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/841022#M36450</link>
      <description>Thank you!</description>
      <pubDate>Wed, 26 Oct 2022 20:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/841022#M36450</guid>
      <dc:creator>Jesusismygrace</dc:creator>
      <dc:date>2022-10-26T20:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: If Then Else Statemen with date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/841023#M36451</link>
      <description>Thank you for the example!</description>
      <pubDate>Wed, 26 Oct 2022 20:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/If-Then-Else-Statemen-with-date-variable/m-p/841023#M36451</guid>
      <dc:creator>Jesusismygrace</dc:creator>
      <dc:date>2022-10-26T20:22:09Z</dc:date>
    </item>
  </channel>
</rss>

