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?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.