How to Sum Vertically

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How to Sum Vertically

Hello All

 

I have a table as follows

 

ID : The ID is Unique value in the sense for a set of rows it will remains same , but the table may contain ID1, ID2,ID3,…IDn varies from case to case

Time : I have only 4 Values in the Table , Time1, Time2, Time 3 and Time4

Group : I have n different Groups starting from Grp1, Grp2, Grp3,…,Grpn from case to case

TimeDiff: Each row will be having a value and may vary from 0 to 123456789

 

Have

ID

Time

Group

TimeDiff

ID1

Time1

Grp1

12371231

ID1

Time1

Grp1

12371231

ID1

Time2

Grp1

54934

ID1

Time2

Grp1

10543254

ID1

Time2

Grp2

1776401

ID1

Time2

Grp2

1776

ID1

Time3

Grp3

9

ID1

Time2

Grp3

522

ID1

Time4

Grp3

0

ID1

Time3

Grp2

13046

ID1

Time3

Grp1

167599

ID2

Time3

Grp1

4990

ID2

Time3

Grp3

0

ID2

Time2

Grp1

11762618

ID2

Time2

Grp3

0

ID2

Time2

Grp2

590

ID2

Time4

Grp3

0

ID2

Time3

Grp2

19738

ID2

Time1

Grp1

11787936

 

I want to sum the TimeDiff if the Group having same value and Time having same value for each ID

 

Have

 

Want

ID

Time

Group

TimeDiff

 

ID

Time

Group

TimeDiff

ID1

Time1

Grp1

12371231

 

ID1

Time1

Grp1

24742462

ID1

Time1

Grp1

12371231

 

ID1

Time2

Grp1

10598188

ID1

Time2

Grp1

54934

     

ID1

Time2

Grp1

10543254

     

 

 

Bellow should be the final table

 

Want

ID

Time

Group

TimeDiff

ID1

Time1

Grp1

24742462

ID1

Time2

Grp1

10598188

ID1

Time2

Grp2

1778177

ID1

Time2

Grp3

522

ID1

Time3

Grp3

9

ID1

Time3

Grp2

13046

ID1

Time3

Grp1

167599

ID1

Time4

Grp3

0

ID2

Time1

Grp1

11787936

ID2

Time2

Grp1

11762618

ID2

Time2

Grp3

0

ID2

Time2

Grp2

590

ID2

Time3

Grp1

4990

ID2

Time3

Grp3

0

ID2

Time3

Grp2

19738

ID2

Time4

Grp3

0


Accepted Solutions
Solution
‎12-20-2016 10:45 PM
Super User
Posts: 17,928

All Replies
Super User
Posts: 17,928

Re: How to Sum Vertically

You need a standard proc means. Look at the CLASS, TYPES, WAYS statements on how to create your groups. 

 

Alternatively, look at PROC SQL and include the identifiers in your GROUP BY statement. 

New Contributor
Posts: 3

Re: How to Sum Vertically

Reeza,

 

Thanks for the reply . I am very new to SAS.

 

Do you have a sample pgm or a doc something which I can refer.

 

True Regards

Siva

Solution
‎12-20-2016 10:45 PM
Super User
Posts: 17,928

Re: How to Sum Vertically

New Contributor
Posts: 3

Re: How to Sum Vertically

Thanks Reeza

 

It worked

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 277 views
  • 0 likes
  • 2 in conversation