<?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: Rolling up in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72982#M15718</link>
    <description>Ops nevermind. I figured it out. Silly quesiton! &lt;BR /&gt;
&lt;BR /&gt;
Thank you again.</description>
    <pubDate>Sat, 18 Sep 2010 03:17:44 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-09-18T03:17:44Z</dc:date>
    <item>
      <title>Rolling up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72977#M15713</link>
      <description>my input datasets looks like this:&lt;BR /&gt;
&lt;BR /&gt;
ID  begindate    enddate     days   month &lt;BR /&gt;
1    20030108   20030110     2       01&lt;BR /&gt;
1    20030115   20030118     4       01&lt;BR /&gt;
1    20030129   20030131     3       01&lt;BR /&gt;
1    20030201   20030205     5       01&lt;BR /&gt;
&lt;BR /&gt;
I wuold like the following output&lt;BR /&gt;
&lt;BR /&gt;
ID  begindate    enddate  &lt;BR /&gt;
1   20030108    20030110  &lt;BR /&gt;
1   20030115    20030118  &lt;BR /&gt;
1   20030129    20030205&lt;BR /&gt;
&lt;BR /&gt;
How do I roll up dates?&lt;BR /&gt;
&lt;BR /&gt;
Thank you. &lt;BR /&gt;
&lt;BR /&gt;
Diego</description>
      <pubDate>Fri, 17 Sep 2010 14:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72977#M15713</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-17T14:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72978#M15714</link>
      <description>You have PROC SQL or PROC MEANS / SUMMARY to use - with MIN/MAX/SUM options to assign/derive output variables.  Check the SAS DOC for these options - also there is much "free" information on the SAS support &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website, including SAS-hosted DOC and supplemental technical / conference topic-related references.&lt;BR /&gt;
&lt;BR /&gt;
Also, you need to identify the "break" or "group by" column/variable - it's not obvious from the data-example provided.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 17 Sep 2010 15:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72978#M15714</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-09-17T15:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72979#M15715</link>
      <description>I just need to roll up contigious dates in different months. In the example the last 3 days of january and the first five days of february need to be combined so that the begin date would be that jan 29 and the end date would be Feb 5th.  That is all I need to do. I wuold have three records instead of 4. &lt;BR /&gt;
&lt;BR /&gt;
Diego</description>
      <pubDate>Fri, 17 Sep 2010 15:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72979#M15715</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-17T15:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72980#M15716</link>
      <description>Here is one way. hth.&lt;BR /&gt;
[pre]&lt;BR /&gt;
/* test data */&lt;BR /&gt;
data one;&lt;BR /&gt;
   input id (begindate enddate) (:anydtdte.);&lt;BR /&gt;
   format begindate enddate yymmdd10.;&lt;BR /&gt;
cards; &lt;BR /&gt;
1 2003-01-08 2003-01-10&lt;BR /&gt;
1 2003-01-15 2003-01-18&lt;BR /&gt;
1 2003-01-29 2003-01-31&lt;BR /&gt;
1 2003-02-01 2003-02-05&lt;BR /&gt;
2 2003-11-29 2003-11-30&lt;BR /&gt;
2 2003-12-01 2003-12-02&lt;BR /&gt;
2 2003-12-03 2003-12-04&lt;BR /&gt;
2 2003-12-05 2003-12-06&lt;BR /&gt;
2 2004-01-01 2004-01-01&lt;BR /&gt;
2 2004-01-02 2004-01-03&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* collapse adjacent spells into one within id. assumed no overlaps. */&lt;BR /&gt;
proc sort data=one;&lt;BR /&gt;
  by id begindate enddate;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data two;&lt;BR /&gt;
  call missing(b);&lt;BR /&gt;
  do until (last.id);&lt;BR /&gt;
    set one end=end;&lt;BR /&gt;
    by id;&lt;BR /&gt;
    if end then do; link doOutput; stop; end;&lt;BR /&gt;
    set one(firstobs=2 keep=begindate rename=(begindate=nextBegindate));&lt;BR /&gt;
    if last.id or enddate + 1 ^= nextBegindate then link doOutput;&lt;BR /&gt;
    else if missing(b) then b = begindate;&lt;BR /&gt;
  end;&lt;BR /&gt;
  return;&lt;BR /&gt;
doOutput:&lt;BR /&gt;
  if not missing(b) then do; &lt;BR /&gt;
     begindate = b;&lt;BR /&gt;
     call missing(b);&lt;BR /&gt;
  end;&lt;BR /&gt;
  output;&lt;BR /&gt;
  keep id begindate enddate;&lt;BR /&gt;
return;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=two noobs;&lt;BR /&gt;
run;&lt;BR /&gt;
/* on lst&lt;BR /&gt;
id     begindate       enddate&lt;BR /&gt;
 1    2003-01-08    2003-01-10&lt;BR /&gt;
 1    2003-01-15    2003-01-18&lt;BR /&gt;
 1    2003-01-29    2003-02-05&lt;BR /&gt;
 2    2003-11-29    2003-12-06&lt;BR /&gt;
 2    2004-01-01    2004-01-03&lt;BR /&gt;
*/&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 17 Sep 2010 21:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72980#M15716</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2010-09-17T21:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72981#M15717</link>
      <description>It works perfetly. THank you very much. &lt;BR /&gt;
May I Ask you? What is doOutput?&lt;BR /&gt;
&lt;BR /&gt;
Thank you again. &lt;BR /&gt;
&lt;BR /&gt;
Diego</description>
      <pubDate>Sat, 18 Sep 2010 03:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72981#M15717</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-18T03:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Rolling up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72982#M15718</link>
      <description>Ops nevermind. I figured it out. Silly quesiton! &lt;BR /&gt;
&lt;BR /&gt;
Thank you again.</description>
      <pubDate>Sat, 18 Sep 2010 03:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rolling-up/m-p/72982#M15718</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-09-18T03:17:44Z</dc:date>
    </item>
  </channel>
</rss>

