BookmarkSubscribeRSS Feed
deleted_user
Not applicable
DATA Temp;
INPUT Group Salary;
CARDS;
1 5000
1 6000
1 2100
2 1110
2 5000
2 5000
3 5000
3 5000
;
RUN;

Data Temp1;
set Temp;
Cum_salary + Salary;
RUN;

But how can i calculate cumulative salary by group?
5 REPLIES 5
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Have you looked at PROC FREQ with the OUT= option?

Scott Barry
SBBWorks, Inc.

Recommended Google advanced search argument:

proc freq cumulative frequency site:sas.com
deleted_user
Not applicable
Data Temp1;
set Temp;
by group;
if first.Group then Cum_salary=Salary;
else Cum_salary + Salary;
RUN;
deleted_user
Not applicable
Thanks~

But if set two group?
It seems no effect......please~

DATA Temp;
INPUT Group1 Group2 Salary;
CARDS;
1 A 5000
1 A 6000
1 B 2100
2 A 1110
2 B 5000
2 B 5000
3 A 5000
3 A 5000
;
RUN;

Data Temp1;
set Temp;
by Group1 Group2;
if first.Group1 & first.Group2 then cum_salary= salary;
else cum_salary+ salary;
run;
deleted_user
Not applicable
try this.

DATA Temp;
INPUT Group1 Group2 $ Salary;
CARDS;
1 A 5000
1 A 6000
1 B 2100
2 A 1110
2 B 5000
2 B 5000
3 A 5000
3 A 5000
;
RUN;

proc sort data=temp;
by Group1 Group2;
run;

Data Temp1;
set Temp;
by Group1 Group2;
if first.Group2 then cum_salary= salary;
else cum_salary+ salary;
run;

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
  • 5 replies
  • 3927 views
  • 0 likes
  • 2 in conversation