<?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: how to transform monthly data to cumulative monthly data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66257#M18908</link>
    <description>how do you manage when you have more variables to classify, following you example, age, color of eyes?&lt;BR /&gt;
would you &lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;if first.sex then genderheight=0;   allheight + height;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
add else and use the other variables?</description>
    <pubDate>Sun, 21 Dec 2008 16:50:10 GMT</pubDate>
    <dc:creator>coba</dc:creator>
    <dc:date>2008-12-21T16:50:10Z</dc:date>
    <item>
      <title>how to transform monthly data to cumulative monthly data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66252#M18903</link>
      <description>I have a data set based on month and I would like to make a cumulative month data set. Could someone help me with the program code?&lt;BR /&gt;
Thanks</description>
      <pubDate>Wed, 17 Dec 2008 14:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66252#M18903</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2008-12-17T14:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to transform monthly data to cumulative monthly data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66253#M18904</link>
      <description>Hi coba&lt;BR /&gt;
Have a look what Proc Summary/Proc Means can do for you.&lt;BR /&gt;
To get a more specific answer you have to provide much more information: What do you have, what do you want - and best some code creating some sample data.&lt;BR /&gt;
Cheers, Patrick</description>
      <pubDate>Wed, 17 Dec 2008 21:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66253#M18904</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-12-17T21:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to transform monthly data to cumulative monthly data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66254#M18905</link>
      <description>sorry that is true, should have be clearer. &lt;BR /&gt;
I have a volumes series link to a month series i.e.&lt;BR /&gt;
date	volume&lt;BR /&gt;
01-Jan-08	5000&lt;BR /&gt;
02-Feb-08	10000&lt;BR /&gt;
05-Mar-08	15000&lt;BR /&gt;
06-Apr-08	5000&lt;BR /&gt;
08-May-08	4000&lt;BR /&gt;
09-Jun-08	1000&lt;BR /&gt;
11-Jul-08	100&lt;BR /&gt;
12-Aug-08	2000&lt;BR /&gt;
out of these series I would like to make the cumulative volume. There must be something with the retain function, not quite sure. Hope you will be able to help</description>
      <pubDate>Thu, 18 Dec 2008 09:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66254#M18905</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2008-12-18T09:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to transform monthly data to cumulative monthly data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66255#M18906</link>
      <description>I manage to make cumulative series, but how do I manage to have by year and by type?&lt;BR /&gt;
data work.cum;&lt;BR /&gt;
input date date7. volume type $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
01jan07 2000 a&lt;BR /&gt;
01feb07 1000 a&lt;BR /&gt;
01jan07 2000 b&lt;BR /&gt;
01feb07 1000 b&lt;BR /&gt;
01jan07 2000 c&lt;BR /&gt;
01feb07 1000 c&lt;BR /&gt;
01jan08 2000 a&lt;BR /&gt;
01feb08 1000 a&lt;BR /&gt;
01jan08 2000 b&lt;BR /&gt;
01feb08 1000 b&lt;BR /&gt;
01jan08 2000 c&lt;BR /&gt;
01feb08 1000 c&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data work.cum2; &lt;BR /&gt;
      set work.cum; &lt;BR /&gt;
	  format date date7.;&lt;BR /&gt;
      retain cumvol 0; &lt;BR /&gt;
      cumvol = sum( cumvol, volume, type);&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 18 Dec 2008 15:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66255#M18906</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2008-12-18T15:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to transform monthly data to cumulative monthly data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66256#M18907</link>
      <description>Hi:&lt;BR /&gt;
  Investigate the use of the BY statement and the FIRST.byvar and LAST.byvar variables.&lt;BR /&gt;
&lt;BR /&gt;
  For example, this output:&lt;BR /&gt;
[pre]&lt;BR /&gt;
Obs    Name       Sex    Age    Height    Weight    allheight    genderheight&lt;BR /&gt;
&lt;BR /&gt;
  1    Alice       F      13     56.5       84.0        56.5          56.5&lt;BR /&gt;
  2    Barbara     F      13     65.3       98.0       121.8         121.8&lt;BR /&gt;
  3    Carol       F      14     62.8      102.5       184.6         184.6&lt;BR /&gt;
  4    Jane        F      12     59.8       84.5       244.4         244.4&lt;BR /&gt;
  5    Janet       F      15     62.5      112.5       306.9         306.9&lt;BR /&gt;
  6    Joyce       F      11     51.3       50.5       358.2         358.2&lt;BR /&gt;
  7    Judy        F      14     64.3       90.0       422.5         422.5&lt;BR /&gt;
  8    Louise      F      12     56.3       77.0       478.8         478.8&lt;BR /&gt;
  9    Mary        F      15     66.5      112.0       545.3         545.3&lt;BR /&gt;
--------------------------------------------------------------------------------------------------&lt;BR /&gt;
 10    Alfred      M      14     69.0      112.5       614.3          69.0&lt;BR /&gt;
 11    Henry       M      14     63.5      102.5       677.8         132.5&lt;BR /&gt;
 12    James       M      12     57.3       83.0       735.1         189.8&lt;BR /&gt;
 13    Jeffrey     M      13     62.5       84.0       797.6         252.3&lt;BR /&gt;
 14    John        M      12     59.0       99.5       856.6         311.3&lt;BR /&gt;
 15    Philip      M      16     72.0      150.0       928.6         383.3&lt;BR /&gt;
 16    Robert      M      12     64.8      128.0       993.4         448.1&lt;BR /&gt;
 17    Ronald      M      15     67.0      133.0      1060.4         515.1&lt;BR /&gt;
 18    Thomas      M      11     57.5       85.0      1117.9         572.6&lt;BR /&gt;
 19    William     M      15     66.5      112.0      1184.4         639.1&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                          &lt;BR /&gt;
created from SASHELP.CLASS, shows a "cumulative height" for all students and a cumulative "gender" height for the females and males. &lt;BR /&gt;
(I put a dividing line between the 2 groups of observations, so you could see that the GENDERHEIGHT variable is reset to 0 when the first M observation is encountered, while the ALLHEIGHT variable keeps accumulating.&lt;BR /&gt;
 &lt;BR /&gt;
The code that produced this output is below.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sort data=sashelp.class out=class;&lt;BR /&gt;
  by sex name;&lt;BR /&gt;
run;&lt;BR /&gt;
                                      &lt;BR /&gt;
data cumclass;&lt;BR /&gt;
  set class;&lt;BR /&gt;
  by sex;&lt;BR /&gt;
  retain allheight genderheight;&lt;BR /&gt;
  if first.sex then genderheight=0;&lt;BR /&gt;
  allheight + height;&lt;BR /&gt;
  genderheight + height;&lt;BR /&gt;
  output;&lt;BR /&gt;
run;&lt;BR /&gt;
                                 &lt;BR /&gt;
options nocenter nodate nonumber;&lt;BR /&gt;
proc print data=cumclass;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 18 Dec 2008 16:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66256#M18907</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-12-18T16:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to transform monthly data to cumulative monthly data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66257#M18908</link>
      <description>how do you manage when you have more variables to classify, following you example, age, color of eyes?&lt;BR /&gt;
would you &lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;if first.sex then genderheight=0;   allheight + height;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
add else and use the other variables?</description>
      <pubDate>Sun, 21 Dec 2008 16:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66257#M18908</guid>
      <dc:creator>coba</dc:creator>
      <dc:date>2008-12-21T16:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to transform monthly data to cumulative monthly data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66258#M18909</link>
      <description>you can derive the cumulative picture across more than one cross-classing, but would they consolidate ?&lt;BR /&gt;
 &lt;BR /&gt;
imagine the data consolidated by &lt;BR /&gt;
age&lt;BR /&gt;
sex&lt;BR /&gt;
 &lt;BR /&gt;
I would recommend making your time-based data complete in the granularity you need (monthly). So you would have a data cell for every age/sex/month&lt;BR /&gt;
Then that can be accumulated where-ever needed.&lt;BR /&gt;
&lt;BR /&gt;
I can imagine many ways of accumulation within some, or all, classings.&lt;BR /&gt;
In a PROC TABULATE step, you might show a column for each month of the period, showing how the statistics "accumulate" over time. [pre]data birthdays ;&lt;BR /&gt;
  set sashelp.class ;&lt;BR /&gt;
  * invent a date of birth based on age and randomly in year;&lt;BR /&gt;
  dob = today() - age*365.25 - 12*30*ranuni(2) ; * testing data ;&lt;BR /&gt;
  bmonth = month( dob );&lt;BR /&gt;
run;&lt;BR /&gt;
 &lt;BR /&gt;
proc summary nway ;&lt;BR /&gt;
   class sex age bmonth ;&lt;BR /&gt;
   var   height ;&lt;BR /&gt;
   output sum= ;&lt;BR /&gt;
run;&lt;BR /&gt;
 &lt;BR /&gt;
data completed ;&lt;BR /&gt;
  s_a_ht = 0 ;&lt;BR /&gt;
  do until( last.age ) ;&lt;BR /&gt;
     set ;&lt;BR /&gt;
     by sex age ;&lt;BR /&gt;
     array cumHt(12) ;&lt;BR /&gt;
     cumHt( bmonth) = height ;&lt;BR /&gt;
     s_a_ht + height ;&lt;BR /&gt;
  end ;&lt;BR /&gt;
  height = s_a_ht ;&lt;BR /&gt;
  * do acumulation over the year ;&lt;BR /&gt;
  do bmonth= 2 to 12 ;&lt;BR /&gt;
     cumHt(bmonth)= sum( cumHt(bmonth), cumht( bmonth-1), 0 );&lt;BR /&gt;
  end ;&lt;BR /&gt;
  keep sex age cumHt1-cumHt12 height ;&lt;BR /&gt;
run;&lt;BR /&gt;
 &lt;BR /&gt;
proc tabulate  format= 5. ;&lt;BR /&gt;
  class sex age ;&lt;BR /&gt;
  var   cumHt1-cumHt12 height;&lt;BR /&gt;
  table (sex*(age all) all)&lt;BR /&gt;
      , sum= 'accumulative totals of Height over year'&lt;BR /&gt;
      * (cumHt1 cumHt2 cumHt3 cumHt4  cumHt5  cumHt6&lt;BR /&gt;
       cumHt7 cumHt8 cumHt9 cumHt10 cumHt11 cumHt12 )&lt;BR /&gt;
        sum= 'total'*height * f=6.  &lt;BR /&gt;
      / rts= 10 ;&lt;BR /&gt;
 label cumHt1 = 'Jan' cumHt2 = 'Feb' cumHt3 = 'Mar' cumHt4 = 'Apr'&lt;BR /&gt;
       cumHt5 = 'May' cumHt6 = 'Jun' cumHt7 = 'Jul' cumHt8 = 'Aug'&lt;BR /&gt;
      cumHt9 = 'Sep' cumHt10= 'Oct' cumHt11= 'Nov' cumHt12= 'Dec';&lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
tested in SAS9.1.3 on win-XP, I got the result[pre]                                          The SAS System      12:14 Monday, December 22, 2008 &lt;BR /&gt;
&lt;BR /&gt;
   .---------------------------------------------------------------------------------------.&lt;BR /&gt;
   |        |                accumulative totals of Height over year                |total |&lt;BR /&gt;
   |        |-----------------------------------------------------------------------+------|&lt;BR /&gt;
   |        | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |Height|&lt;BR /&gt;
   |--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |Sex|Age |     |     |     |     |     |     |     |     |     |     |     |     |      |&lt;BR /&gt;
   |---+----|     |     |     |     |     |     |     |     |     |     |     |     |      |&lt;BR /&gt;
   |F  |11  |    .|    0|    0|    0|   51|   51|   51|   51|   51|   51|   51|   51|    51|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |12  |    .|    0|    0|   56|   56|   56|   56|   56|   56|   56|  116|  116|   116|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |13  |   57|   57|  122|  122|  122|  122|  122|  122|  122|  122|  122|  122|   122|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |14  |    .|    0|    0|    0|    0|   63|   63|   63|   63|   63|   63|  127|   127|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |15  |    .|    0|    0|    0|    0|    0|    0|    0|    0|    0|  129|  129|   129|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |All |   57|   57|  122|  178|  229|  292|  292|  292|  292|  292|  481|  545|   545|&lt;BR /&gt;
   |---+----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |M  |Age |     |     |     |     |     |     |     |     |     |     |     |     |      |&lt;BR /&gt;
   |   |----|     |     |     |     |     |     |     |     |     |     |     |     |      |&lt;BR /&gt;
   |   |11  |    .|    0|    0|    0|    0|    0|    0|   58|   58|   58|   58|   58|    58|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |12  |   57|   57|   57|   57|  122|  122|  122|  122|  122|  122|  181|  181|   181|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |13  |    .|    0|    0|    0|    0|    0|    0|    0|    0|    0|   63|   63|    63|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |14  |    .|   64|   64|   64|   64|   64|   64|  133|  133|  133|  133|  133|   133|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |15  |   67|   67|   67|   67|   67|  134|  134|  134|  134|  134|  134|  134|   134|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |16  |   72|   72|   72|   72|   72|   72|   72|   72|   72|   72|   72|   72|    72|&lt;BR /&gt;
   |   |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |   |All |  196|  259|  259|  259|  324|  391|  391|  518|  518|  518|  639|  639|   639|&lt;BR /&gt;
   |--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|&lt;BR /&gt;
   |All     |  252|  316|  381|  437|  554|  683|  683|  810|  810|  810| 1120| 1184|  1184|&lt;BR /&gt;
   '---------------------------------------------------------------------------------------'[/pre]&lt;BR /&gt;
&lt;BR /&gt;
hey&lt;BR /&gt;
&lt;BR /&gt;
is there a set of line-drawing characters to make that look better, or use SAS Monospace ?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Mon, 22 Dec 2008 16:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-transform-monthly-data-to-cumulative-monthly-data/m-p/66258#M18909</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-12-22T16:25:47Z</dc:date>
    </item>
  </channel>
</rss>

