<?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 Finding Missing Values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847817#M36972</link>
    <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;I have data of when hypothetical patients received a certain type of surgery. The type of surgery is denoted by the variable 'condx'. The data states what date the patient received the surgery and how old the they were on that date. Some patients had more than one procedure and on different days, but the patients' ages on those following dates are missing.&lt;STRONG&gt; I would like to know how to use AGE and EVENT_DATE on the first patient record in order to calculate AGE on later dates by comparing EVENT_DATEs. &lt;/STRONG&gt;I am trying to put those missing ages in a new column I named "DIFF". I used the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;RETAIN AGE;
IF LAST.AGE= . THEN AGE=DIFF;
DIFF= LAST.EVENT_DATE-FIRST.EVENT_DATE

RUN;
PROC PRINT DATA=PROJECT.COMPLETE;
RUN;&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;My initial assumption was to find the difference in the dates which would give me the amount of days between dates, however I don't believe this is correct. Thanks in advance for any input.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Dec 2022 19:03:45 GMT</pubDate>
    <dc:creator>nmkz</dc:creator>
    <dc:date>2022-12-05T19:03:45Z</dc:date>
    <item>
      <title>Finding Missing Values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847817#M36972</link>
      <description>&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;I have data of when hypothetical patients received a certain type of surgery. The type of surgery is denoted by the variable 'condx'. The data states what date the patient received the surgery and how old the they were on that date. Some patients had more than one procedure and on different days, but the patients' ages on those following dates are missing.&lt;STRONG&gt; I would like to know how to use AGE and EVENT_DATE on the first patient record in order to calculate AGE on later dates by comparing EVENT_DATEs. &lt;/STRONG&gt;I am trying to put those missing ages in a new column I named "DIFF". I used the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;RETAIN AGE;
IF LAST.AGE= . THEN AGE=DIFF;
DIFF= LAST.EVENT_DATE-FIRST.EVENT_DATE

RUN;
PROC PRINT DATA=PROJECT.COMPLETE;
RUN;&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;My initial assumption was to find the difference in the dates which would give me the amount of days between dates, however I don't believe this is correct. Thanks in advance for any input.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 19:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847817#M36972</guid>
      <dc:creator>nmkz</dc:creator>
      <dc:date>2022-12-05T19:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Missing Values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847818#M36973</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    retain dob;
    if first.pt_id then dob=event_date - round(age*365.25);
    if missing(age) then age=(event_date - dob)/365.25;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is untested code, as we cannot test code against data provided in screen captures. We would need data provided in SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;instructions&lt;/A&gt;) if you want tested code.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 16:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847818#M36973</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-05T16:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Missing Values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847825#M36974</link>
      <description>&lt;P&gt;Thanks for responding. I may not need code tested at this moment. I more so wanted to know what is the correct approach to this situation/problem.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 16:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847825#M36974</guid>
      <dc:creator>nmkz</dc:creator>
      <dc:date>2022-12-05T16:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Missing Values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847826#M36975</link>
      <description>&lt;P&gt;Since FIRST. and LAST. flags are boolean the difference between than could only ever result in values of -1,0 or 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to remember the first date then you need to retain it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by pt_id&amp;nbsp;event_date;
&amp;nbsp;&amp;nbsp;if&amp;nbsp;first.pt_id&amp;nbsp;then&amp;nbsp;first_date&amp;nbsp;=&amp;nbsp;event_date;
&amp;nbsp;&amp;nbsp;format&amp;nbsp;event_date&amp;nbsp;mmddyy10.;
&amp;nbsp;&amp;nbsp;diff&amp;nbsp;=&amp;nbsp;event_date&amp;nbsp;-&amp;nbsp;first_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2022 16:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-Missing-Values/m-p/847826#M36975</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-05T16:20:10Z</dc:date>
    </item>
  </channel>
</rss>

