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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 4682 views
  • 0 likes
  • 2 in conversation