BookmarkSubscribeRSS Feed
odmhx
Calcite | Level 5
In proc report, I need to display each year's spending for 4 years, but only summarize 3 years at year break level. How do I do that?

Your help is appreciated!
4 REPLIES 4
ChrisNZ
Tourmaline | Level 20
You can use this example to get you started:
[pre]
proc report data=sashelp.class;
column SEX AGE WEIGHT ;
define SEX / group;
define AGE / group;
define WEIGHT / analysis sum;
compute after AGE ;
if AGE>13 then TOTAL + WEIGHT.sum;
endcomp;
compute before SEX;
TOTAL=.;
endcomp;
compute after SEX;
line @ 20 ' Sum for ' SEX $1. ' age > 13: ' TOTAL 4.;
endcomp;
run;
odmhx
Calcite | Level 5
Thank you for your code. However, what I was trying to do was not to calculate the sum of female, but only to calculate the sum of the male.. So the output would look like this:

Listing of NUMBERS Data Set

S
e
x Age Weight
F 11 50.5
12 161.5
13 182
14 192.5
15 224.5

M 11 85
12 310.5
13 84
14 215
15 245
16 150
Sum for M age > 13: 610
data_null__
Jade | Level 19
This this small modification to the (LINE) section of the code supplied by Chris.

[pre]
options ls=64;
proc report data=sashelp.class nowd list;
column SEX AGE WEIGHT ;
define SEX / group;
define AGE / group;
define WEIGHT / analysis sum;
compute after AGE ;
if AGE>13 then TOTAL + WEIGHT.sum;
endcomp;
compute before SEX;
TOTAL=.;
endcomp;
compute after SEX;
line = catx(' ','Sum for', sex,'age > 13:',total);
l = length(line);
if sex eq 'F' then l=0;
line @20 line $varying50. l;
*line @ 20 ' Sum for ' SEX $1. ' age > 13: ' TOTAL 4.;
endcomp;
run;
[/pre]
odmhx
Calcite | Level 5
Thank you so much! It really solves my problem!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 827 views
  • 0 likes
  • 3 in conversation