<?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: Creating a New Variable if Death_Date is present in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285152#M58242</link>
    <description>&lt;P&gt;It depends on your variable type, numeric or character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In character variables missing is represented as a blank, and this can be denoted with empty quotes ("")&lt;/P&gt;
&lt;P&gt;A numeric variable has a . when missing and you can check for this with (.) no quotation marks required.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If date_char = "" then death = 0; else death = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If date_num = . Then death = 1; else death =0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can bypass that issue entirely and use the MISSING() function as demonstrated in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;code. Personally I like that option as it's easy to read.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2016 05:53:21 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-07-18T05:53:21Z</dc:date>
    <item>
      <title>Creating a New Variable if Death_Date is present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285149#M58240</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a dummy variable for the patient data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Patients 10002, 10003, 10004 were dead, and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Patients 10005, 10006, 10007 have survived so far. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-----------------------------------------------&lt;/P&gt;
&lt;P&gt;Patient_ID &amp;nbsp; &amp;nbsp; &amp;nbsp;Death_Date&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2013-06-04&lt;/P&gt;
&lt;P&gt;10003 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2011-08-15&lt;/P&gt;
&lt;P&gt;10004 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-12-14&lt;/P&gt;
&lt;P&gt;10005&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10006&lt;/P&gt;
&lt;P&gt;10007&lt;/P&gt;
&lt;P&gt;---------------------------------------------&lt;/P&gt;
&lt;P&gt;Depending on if Death_Date is present or not, I want to make &amp;nbsp;a&amp;nbsp;new variable DEATH (1= Death, 0=Surived)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so I tried the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data w.patient;&lt;/P&gt;
&lt;P&gt;set w.patient;&lt;/P&gt;
&lt;P&gt;Death=.;&lt;/P&gt;
&lt;P&gt;if (Death_Date=".") then Death = 1&lt;/P&gt;
&lt;P&gt;if (Death_Date=" ") then Death = 0&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it is marking all the death&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What have I done wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice or help would be appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S Ultimately, I want to make my data set as &amp;nbsp;the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-----------------------------------------------&lt;/P&gt;
&lt;P&gt;Patient_ID &amp;nbsp; &amp;nbsp; &amp;nbsp;Death_Date &amp;nbsp; &amp;nbsp; Death&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10002 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2013-06-04 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;10003 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2011-08-15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;10004 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2012-12-14 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;10005 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;10006 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;10007 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;
&lt;P&gt;---------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 05:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285149#M58240</guid>
      <dc:creator>sasworker16</dc:creator>
      <dc:date>2016-07-18T05:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help: Creating a New Variable if Death_Date is present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285150#M58241</link>
      <description>&lt;P&gt;data w.patient;&lt;/P&gt;
&lt;P&gt;set w.patient;&lt;/P&gt;
&lt;P&gt;if missing(Death_Date) then Death = 0 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;else Death = 1;&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 05:41:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285150#M58241</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-18T05:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a New Variable if Death_Date is present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285152#M58242</link>
      <description>&lt;P&gt;It depends on your variable type, numeric or character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In character variables missing is represented as a blank, and this can be denoted with empty quotes ("")&lt;/P&gt;
&lt;P&gt;A numeric variable has a . when missing and you can check for this with (.) no quotation marks required.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If date_char = "" then death = 0; else death = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;If date_num = . Then death = 1; else death =0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can bypass that issue entirely and use the MISSING() function as demonstrated in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;code. Personally I like that option as it's easy to read.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2016 05:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285152#M58242</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-18T05:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help: Creating a New Variable if Death_Date is present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285172#M58255</link>
      <description>&lt;P&gt;Just to add to your great solution&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;, this would be a great example for the IFN/IFC functions - i.e. a binary yes or no choice:&lt;/P&gt;
&lt;PRE&gt;data w.patient;
  set w.patient;
  death=ifn(missing(Death_Date),0,1);
run; &lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jul 2016 08:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/285172#M58255</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-07-18T08:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Please Help: Creating a New Variable if Death_Date is present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/286007#M58589</link>
      <description>&lt;P&gt;Thank you so much!!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 00:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-New-Variable-if-Death-Date-is-present/m-p/286007#M58589</guid>
      <dc:creator>sasworker16</dc:creator>
      <dc:date>2016-07-21T00:22:13Z</dc:date>
    </item>
  </channel>
</rss>

