<?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 how to get first obs value of start date and last obs value of end date where multiple obs present in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349308#M80998</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;In my data, each subject has startdate(sdate) enddate(edate) of dose of a drug taken. For the derivation an variable I need an output dataset with first.sdate of each subject and last.edate of each subject. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output need;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sdate &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;edate&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05OCT2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;SPAN&gt;0OCT2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05OCT2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 29OCT2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;06OCT2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25OCT2015&lt;/SPAN&gt;&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;data one;
input id sdate  edate date9.
datalines;
1 05OCT2015 06OCT2015
1 06OCT2015 17OCT2015
1 17OCT2015 30OCT2015
2 05OCT2015 10OCT2015
2 11OCT2015 20OCT2015
2 20OCT2015 25OCT2015
2 26OCT2015 29OCT2015
3 06OCT2015 17OCT2015
3 17OCT2015 25OCT2015
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Apr 2017 03:35:58 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2017-04-12T03:35:58Z</dc:date>
    <item>
      <title>how to get first obs value of start date and last obs value of end date where multiple obs present</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349308#M80998</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;In my data, each subject has startdate(sdate) enddate(edate) of dose of a drug taken. For the derivation an variable I need an output dataset with first.sdate of each subject and last.edate of each subject. Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output need;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sdate &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;edate&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05OCT2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;SPAN&gt;0OCT2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;05OCT2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 29OCT2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;06OCT2015 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25OCT2015&lt;/SPAN&gt;&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;data one;
input id sdate  edate date9.
datalines;
1 05OCT2015 06OCT2015
1 06OCT2015 17OCT2015
1 17OCT2015 30OCT2015
2 05OCT2015 10OCT2015
2 11OCT2015 20OCT2015
2 20OCT2015 25OCT2015
2 26OCT2015 29OCT2015
3 06OCT2015 17OCT2015
3 17OCT2015 25OCT2015
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Apr 2017 03:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349308#M80998</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-04-12T03:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to get first obs value of start date and last obs value of end date where multiple obs prese</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349309#M80999</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data one;&lt;BR /&gt;input id sdate : date9. edate :date9.;&lt;BR /&gt;format sdate edate date9.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 05OCT2015 06OCT2015&lt;BR /&gt;1 06OCT2015 17OCT2015&lt;BR /&gt;1 17OCT2015 30OCT2015&lt;BR /&gt;2 05OCT2015 10OCT2015&lt;BR /&gt;2 11OCT2015 20OCT2015&lt;BR /&gt;2 20OCT2015 25OCT2015&lt;BR /&gt;2 26OCT2015 29OCT2015&lt;BR /&gt;3 06OCT2015 17OCT2015&lt;BR /&gt;3 17OCT2015 25OCT2015&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set one;&lt;BR /&gt;by id;&lt;BR /&gt;retain _sdate;&lt;BR /&gt;if first.id then _sdate=sdate;&lt;BR /&gt;else if last.id then sdate=_sdate;&lt;BR /&gt;if last.id;&lt;BR /&gt;drop _sdate;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen Srinivasan&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 03:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349309#M80999</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-04-12T03:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to get first obs value of start date and last obs value of end date where multiple obs prese</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349333#M81007</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc SQL;
  Create Table Want As
    Select id,
	  Min(sdate) as sdate Format=Date9.,
	  Max(edate) as edate Format=Date9.
    From one
    Group By id;
Quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Apr 2017 06:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349333#M81007</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2017-04-12T06:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to get first obs value of start date and last obs value of end date where multiple obs prese</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349496#M81062</link>
      <description>&lt;P&gt;If there are no other variables involved:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc summary data=have nway;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var sdate edate;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ouput out=want(drop= _:) min(sdate)= max(edate)=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 15:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-get-first-obs-value-of-start-date-and-last-obs-value-of/m-p/349496#M81062</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-12T15:49:31Z</dc:date>
    </item>
  </channel>
</rss>

