I have a summary table that summarizes data how I need it. I need to generate a table that has that same information summarized but into a new table (showing the actual summaries not each line of data used to create the summary report. I don't know how to create a table in sas that only shows the sum of rows so I have used the summary table function (sum) then exported it into excel and attempted to cut and paste it into a spreadsheet with the correct formatting. Can you help me create a new table (not summary data table function) that summarizes distinct rows based on certain criteria so I can then merge that summarized data into another spreadsheet? In the final summary table the posted date does not matter as the week is already present in the table, however there are multiple entries on any given date in that week, there for it needs to be summarized. I need to know how many total units, per material, per plant, per week.
Example below:
Data Table 1 currently in SAS:
Material Code | Plant | Total | Posted Date | Week |
N384000 | 2001 | 100 | 1/1 | 1 |
N384000 | 2001 | 200 | 1/5 | 1 |
N384000 | 2001 | 300 | 1/3 | 1 |
N384000 | 2002 | 100 | 1/4 | 1 |
N384000 | 2003 | 150 | 1/4 | 1 |
N384000 | 2001 | 900 | 1/10 | 2 |
N384000 | 2002 | 50 | 1/11 | 2 |
N384000 | 2002 | 0 | 1/10 | 2 |
N384000 | 2003 | 75 | 1/10 | 2 |
N384000 | 2004 | 0 | 1/13 | 2 |
N463375 | 2001 | 100 | 1/1 | 1 |
N463375 | 2002 | 200 | 1/2 | 1 |
N463375 | 2003 | 100 | 1/4 | 1 |
N463375 | 2004 | 50 | 1/4 | 1 |
N463375 | 2004 | 75 | 1/6 | 1 |
N463375 | 2001 | 0 | 1/11 | 2 |
N463375 | 2002 | 150 | 1/11 | 2 |
N463375 | 2003 | 200 | 1/10 | 2 |
N463375 | 2003 | 200 | 1/10 | 2 |
N463375 | 2004 | 200 | 1/13 | 2 |
Data Table I need in SAS:
Material Code | Plant | Total Sum | Week |
N384000 | 2001 | 600 | 1 |
N384000 | 2002 | 100 | 1 |
N384000 | 2003 | 150 | 1 |
N384000 | 2004 | 0 | 1 |
N384000 | 2001 | 900 | 2 |
N384000 | 2002 | 100 | 2 |
N384000 | 2003 | 150 | 2 |
N384000 | 2004 | 0 | 2 |
N463375 | 2001 | 100 | 1 |
N463375 | 2002 | 200 | 1 |
N463375 | 2003 | 100 | 1 |
N463375 | 2004 | 125 | 1 |
N463375 | 2001 | 0 | 2 |
N463375 | 2002 | 150 | 2 |
N463375 | 2003 | 400 | 2 |
N463375 | 2004 | 200 | 2 |
Can you help me?
I'm not 100% clear on what you're after, but this PROC MEANS run shows how to do that kind of summarization. Hopefully it will get you on track!
Tom
data have;
length Material $10 Plant 8 Total 8 Posted $10 Week 8;
input Material Plant Total Posted Week;
cards;
N384000 2001 100 1/1 1
N384000 2001 200 1/5 1
N384000 2001 300 1/3 1
N384000 2002 100 1/4 1
N384000 2003 150 1/4 1
N384000 2001 900 1/10 2
N384000 2002 50 1/11 2
N384000 2002 0 1/10 2
N384000 2003 75 1/10 2
N384000 2004 0 1/13 2
N463375 2001 100 1/1 1
N463375 2002 200 1/2 1
N463375 2003 100 1/4 1
N463375 2004 50 1/4 1
N463375 2004 75 1/6 1
N463375 2001 0 1/11 2
N463375 2002 150 1/11 2
N463375 2003 200 1/10 2
N463375 2003 200 1/10 2
N463375 2004 200 1/13 2
run;
proc means data=have noprint nway;
class Material Plant Week;
var Total;
output out=want sum()=TotalSum;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.