<?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: Calculate the Surgery_Date from Surgery_Duration value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578659#M164158</link>
    <description>&lt;P&gt;I would suggest to calculate the number of days and then just adding that to the record_date to get your DateonSurg.&lt;/P&gt;</description>
    <pubDate>Fri, 02 Aug 2019 11:08:14 GMT</pubDate>
    <dc:creator>Criptic</dc:creator>
    <dc:date>2019-08-02T11:08:14Z</dc:date>
    <item>
      <title>Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578649#M164149</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the Surgery_date value from the Surgery_Duration.&lt;/P&gt;&lt;P&gt;Kindly go through the given sample dataset.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Record_date mmddyy10. Duration DuratIn$.;
format Record_date mmddyy10.;
cards;
101 03/05/2001 7.6 Years
102 04/02/2001 6 Months
103 03/08/2003 2.06 Years
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Expected OP:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Record_date&lt;/TD&gt;&lt;TD&gt;Duration&lt;/TD&gt;&lt;TD&gt;DuratIn&lt;/TD&gt;&lt;TD&gt;DateonSurg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;03/05/2001&lt;/TD&gt;&lt;TD&gt;7.6&lt;/TD&gt;&lt;TD&gt;Year&lt;/TD&gt;&lt;TD&gt;09/05/2008&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;102&lt;/TD&gt;&lt;TD&gt;04/02/2001&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;Month&lt;/TD&gt;&lt;TD&gt;10/02/2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;103&lt;/TD&gt;&lt;TD&gt;03/08/2003&lt;/TD&gt;&lt;TD&gt;2.06&lt;/TD&gt;&lt;TD&gt;Year&lt;/TD&gt;&lt;TD&gt;03/14/2005&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please Suggest some ideas to solve the case.&lt;/P&gt;&lt;P&gt;Much Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 10:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578649#M164149</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-08-02T10:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578654#M164153</link>
      <description>&lt;P&gt;In the last line of your example, you don't add 2.06 years, but 2 years an 6 days, is this correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;ID&lt;/SPAN&gt; Record_date mmddyy10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; Duration DuratIn&lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;format&lt;/SPAN&gt; Record_date mmddyy10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
101 03/05/2001 7.6 Years
102 04/02/2001 6 Months
103 03/08/2003 2.06 Years
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is this the version of your data we should use, or will there be further changes?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 10:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578654#M164153</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-08-02T10:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578657#M164156</link>
      <description>&lt;P&gt;Sorry for an inconvenience&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are absolutely right (2.6 years). There are no&amp;nbsp;&lt;SPAN&gt;further changes required.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have to calculate the surgery date using the Record_date and Surgery_Duration. That's it&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 11:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578657#M164156</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-08-02T11:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578659#M164158</link>
      <description>&lt;P&gt;I would suggest to calculate the number of days and then just adding that to the record_date to get your DateonSurg.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 11:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578659#M164158</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2019-08-02T11:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578663#M164161</link>
      <description>&lt;P&gt;Maybe something like this, but i am not sure that i fully understood the decimal place and how they should be used in the calculation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;

   attrib DateonSurg length=8 format=mmddyy10.;

   select (DuratIn);
      when ('Years') do;
         y = int(Duration);
         m = int((Duration - y) * 10);
         d = int((Duration - y - m/10) * 100);
      end;
      when ('Months') do;
         y = 0;
         m = int(Duration);
         d = 0; /* maybe wrong, no data to check */
      end;
      otherwise put 'ERROR: DuratIn' DuratIn 'is not yet implemented';
   end;

   DateOnSurg = intnx('Year', Record_date, y, 's');
   DateOnSurg = intnx('month', DateOnSurg, m, 's');
   DateOnSurg = intnx('day', DateOnSurg, d, 's');

   drop y m d;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Aug 2019 11:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578663#M164161</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-08-02T11:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578673#M164163</link>
      <description>&lt;P&gt;Here could give you a start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Record_date : mmddyy10. Duration DuratIn $;
format Record_date mmddyy10.;
cards;
101 03/05/2001 7.6 Years
102 04/02/2001 6 Months
103 03/08/2003 2.6 Years
;

data want;
 set have;
 if DuratIn='Years' then do;
   n=ceil(duration);
   do i=Record_date to intnx('year',Record_date,n);
    if round(yrdif(Record_date,i,'act/act'),0.1)=round(Duration,0.1) then do;
     want=i;leave;end;
   end;
 end;
 format want mmddyy10.;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Aug 2019 12:09:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578673#M164163</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-02T12:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578679#M164167</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp; . Your code works well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what is the alternate line if Days exist for&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;d &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;int&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Duration &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; y &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; m&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;100&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 12:39:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578679#M164167</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-08-02T12:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578702#M164175</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your time and consideration. Your code works well for Year rows.&lt;/P&gt;&lt;P&gt;The Month parameter looks empty.&lt;/P&gt;&lt;P&gt;Could you please go through the month parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 13:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578702#M164175</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2019-08-02T13:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578750#M164190</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215282"&gt;@Sathish_jammy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp; . Your code works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what is the alternate line if Days exist for&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;d &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;int&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Duration &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; y &lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt; m&lt;SPAN class="token operator"&gt;/&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;10&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;100&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry, but i don't understand the question.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2019 15:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578750#M164190</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-08-02T15:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the Surgery_Date from Surgery_Duration value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578889#M164260</link>
      <description>&lt;P&gt;If you want take .6 as semi-year , . 2 as two months ,&lt;/P&gt;
&lt;P&gt;I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp; has already given you great solution.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Aug 2019 11:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-Surgery-Date-from-Surgery-Duration-value/m-p/578889#M164260</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-03T11:13:08Z</dc:date>
    </item>
  </channel>
</rss>

