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 |
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.
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
Thanks Reeza
It worked
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.