you can derive the cumulative picture across more than one cross-classing, but would they consolidate ?
imagine the data consolidated by
age
sex
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
Then that can be accumulated where-ever needed.
I can imagine many ways of accumulation within some, or all, classings.
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 ;
set sashelp.class ;
* invent a date of birth based on age and randomly in year;
dob = today() - age*365.25 - 12*30*ranuni(2) ; * testing data ;
bmonth = month( dob );
run;
proc summary nway ;
class sex age bmonth ;
var height ;
output sum= ;
run;
data completed ;
s_a_ht = 0 ;
do until( last.age ) ;
set ;
by sex age ;
array cumHt(12) ;
cumHt( bmonth) = height ;
s_a_ht + height ;
end ;
height = s_a_ht ;
* do acumulation over the year ;
do bmonth= 2 to 12 ;
cumHt(bmonth)= sum( cumHt(bmonth), cumht( bmonth-1), 0 );
end ;
keep sex age cumHt1-cumHt12 height ;
run;
proc tabulate format= 5. ;
class sex age ;
var cumHt1-cumHt12 height;
table (sex*(age all) all)
, sum= 'accumulative totals of Height over year'
* (cumHt1 cumHt2 cumHt3 cumHt4 cumHt5 cumHt6
cumHt7 cumHt8 cumHt9 cumHt10 cumHt11 cumHt12 )
sum= 'total'*height * f=6.
/ rts= 10 ;
label cumHt1 = 'Jan' cumHt2 = 'Feb' cumHt3 = 'Mar' cumHt4 = 'Apr'
cumHt5 = 'May' cumHt6 = 'Jun' cumHt7 = 'Jul' cumHt8 = 'Aug'
cumHt9 = 'Sep' cumHt10= 'Oct' cumHt11= 'Nov' cumHt12= 'Dec';
run;[/pre]
tested in SAS9.1.3 on win-XP, I got the result[pre] The SAS System 12:14 Monday, December 22, 2008
.---------------------------------------------------------------------------------------.
| | accumulative totals of Height over year |total |
| |-----------------------------------------------------------------------+------|
| | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |Height|
|--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
|Sex|Age | | | | | | | | | | | | | |
|---+----| | | | | | | | | | | | | |
|F |11 | .| 0| 0| 0| 51| 51| 51| 51| 51| 51| 51| 51| 51|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |12 | .| 0| 0| 56| 56| 56| 56| 56| 56| 56| 116| 116| 116|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |13 | 57| 57| 122| 122| 122| 122| 122| 122| 122| 122| 122| 122| 122|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |14 | .| 0| 0| 0| 0| 63| 63| 63| 63| 63| 63| 127| 127|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |15 | .| 0| 0| 0| 0| 0| 0| 0| 0| 0| 129| 129| 129|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |All | 57| 57| 122| 178| 229| 292| 292| 292| 292| 292| 481| 545| 545|
|---+----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
|M |Age | | | | | | | | | | | | | |
| |----| | | | | | | | | | | | | |
| |11 | .| 0| 0| 0| 0| 0| 0| 58| 58| 58| 58| 58| 58|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |12 | 57| 57| 57| 57| 122| 122| 122| 122| 122| 122| 181| 181| 181|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |13 | .| 0| 0| 0| 0| 0| 0| 0| 0| 0| 63| 63| 63|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |14 | .| 64| 64| 64| 64| 64| 64| 133| 133| 133| 133| 133| 133|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |15 | 67| 67| 67| 67| 67| 134| 134| 134| 134| 134| 134| 134| 134|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |16 | 72| 72| 72| 72| 72| 72| 72| 72| 72| 72| 72| 72| 72|
| |----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
| |All | 196| 259| 259| 259| 324| 391| 391| 518| 518| 518| 639| 639| 639|
|--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
|All | 252| 316| 381| 437| 554| 683| 683| 810| 810| 810| 1120| 1184| 1184|
'---------------------------------------------------------------------------------------'[/pre]
hey
is there a set of line-drawing characters to make that look better, or use SAS Monospace ?
PeterC