BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BlayLay
Obsidian | Level 7

Hi Everyone,

 

I have a table (example of current & what i'm looking for) and am not sure which data or proc statement is best to accomplish this and if I need to list out every column name that needs summed.

 

Current Table:

Date ID Weight Height Length Miles
11/10/2020 A123D 4.5 3 5 15
11/10/2020 A123D 5.5 5 7 10
11/10/2020 B456E 7.0 4 3 20
11/12/2020 B456E 6.0 6 8 12
11/12/2020 A123D 8.0 2 4 17

 

Look to sum by Date and ID, to hopefully get something like this:

Date ID Weight Height Length Miles
11/10/2020 A123D 10 8 12 25
11/10/2020 B456E 7.0 4 3 20
11/12/2020 B456E 6.0 6 8 12
11/12/2020 A123D 8.0 2 4 17
1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input Date :mmddyy10. ID $ Weight Height Length Miles;
format date mmddyy10.;
datalines;
11/10/2020 A123D 4.5 3 5 15
11/10/2020 A123D 5.5 5 7 10
11/10/2020 B456E 7.0 4 3 20
11/12/2020 B456E 6.0 6 8 12
11/12/2020 A123D 8.0 2 4 17
;

proc summary data = have nway;
   class Date ID;
   var Weight Height Length Miles;
   output out = want(drop = _:) sum=;
run;

 

Result:

 

Date       ID    Weight Height Length Miles 
11/10/2020 A123D 10     8      12     25 
11/10/2020 B456E 7      4      3      20 
11/12/2020 A123D 8      2      4      17 
11/12/2020 B456E 6      6      8      12 

 

 

View solution in original post

1 REPLY 1
PeterClemmensen
Tourmaline | Level 20

Try this

 

data have;
input Date :mmddyy10. ID $ Weight Height Length Miles;
format date mmddyy10.;
datalines;
11/10/2020 A123D 4.5 3 5 15
11/10/2020 A123D 5.5 5 7 10
11/10/2020 B456E 7.0 4 3 20
11/12/2020 B456E 6.0 6 8 12
11/12/2020 A123D 8.0 2 4 17
;

proc summary data = have nway;
   class Date ID;
   var Weight Height Length Miles;
   output out = want(drop = _:) sum=;
run;

 

Result:

 

Date       ID    Weight Height Length Miles 
11/10/2020 A123D 10     8      12     25 
11/10/2020 B456E 7      4      3      20 
11/12/2020 A123D 8      2      4      17 
11/12/2020 B456E 6      6      8      12 

 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1031 views
  • 4 likes
  • 2 in conversation