BookmarkSubscribeRSS Feed
maliksmom2000
Obsidian | Level 7

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 CodePlantTotalPosted DateWeek
N38400020011001/11
N38400020012001/51
N38400020013001/31
N38400020021001/41
N38400020031501/41
N38400020019001/102
N3840002002501/112
N384000200201/102
N3840002003751/102
N384000200401/132
N46337520011001/11
N46337520022001/21
N46337520031001/41
N4633752004501/41
N4633752004751/61
N463375200101/112
N46337520021501/112
N46337520032001/102
N46337520032001/102
N46337520042001/132

Data Table I need in SAS:

Material CodePlantTotal SumWeek
N38400020016001
N38400020021001
N38400020031501
N384000200401
N38400020019002
N38400020021002
N38400020031502
N384000200402
N46337520011001
N46337520022001
N46337520031001
N46337520041251
N463375200102
N46337520021502
N46337520034002
N46337520042002

 

Can you help me?

 

 

1 REPLY 1
TomKari
Onyx | Level 15

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 372 views
  • 0 likes
  • 2 in conversation