Hi, Below is the dataset that I have. i want to calculate sum of weekday 1&7(10450+34876) and sum of weekday 2 to 6(5670+78201+..)
How can I do that?
Thanks for all your help
weekday sum
1 10450
2 5670
3 78201
4 8723
5 60981
6 8921
7 34876
One way is to create format that will group values as you want.
proc format library=work; value myweekdays 1,7 = '1 7' 2 - 6 = '2 to 6' ; run; data have; input weekday sum; datalines; 1 10450 2 5670 3 78201 4 8723 5 60981 6 8921 7 34876 ; proc means data=have sum; class weekday; format weekday myweekdays.; var sum; run;
Groups of values created with a format can be used in almost any analysis, graphing or reporting procedure to create the needed groups.
One way is to create format that will group values as you want.
proc format library=work; value myweekdays 1,7 = '1 7' 2 - 6 = '2 to 6' ; run; data have; input weekday sum; datalines; 1 10450 2 5670 3 78201 4 8723 5 60981 6 8921 7 34876 ; proc means data=have sum; class weekday; format weekday myweekdays.; var sum; run;
Groups of values created with a format can be used in almost any analysis, graphing or reporting procedure to create the needed groups.
It worked! Thank you.
In the actual data:
You only expect 2 numbers at the end?
The first field is not a date?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.