Help using Base SAS procedures

Group information

Reply
N/A
Posts: 0

Group information

I have information of selling by date and I've already have the week number for each observation, now I need to consolidate it by week

Table content

Date.............Client......Sku......Week.....Volume
01/10/08.......3010......9999....40.............10
02/10/08...... 3010......9999....40.............05
03/10/08...... 3010......9999....40.............30

01/10/08.......3010......8888....40.............20
02/10/08...... 3010......8888....40.............10
03/10/08...... 3010......8888....40.............60

01/10/08.......4000......5555....40............02
02/10/08...... 4000......5555....40............01
02/10/08...... 4000......5555....40...........01

01/10/08.......4000......3333....40............10
02/10/08...... 4000......3333....40............01
02/10/08...... 4000......3333....40...........01


Output expected

Client.....Sku.....Week.....Volume
3010......9999.....40.........45
3010......8888....40..........80
4000......5555.....40....... 04
4000.....3333......40...... 12

Thanks
Super Contributor
Super Contributor
Posts: 3,174

Re: Group information

Investigate using SAS PROC SUMMARY.

Scott Barry
SBBWorks, Inc.

SAS 9.2 DOC: The SUMMARY Procedure
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000146755.htm
N/A
Posts: 0

Re: Group information

Hope the following the code helps:

proc sql;
create table test2 as
select client, week, sku, sum(volume) as volume
from testdata
group by sku
quit;

proc sort data=test2;
by sku;
run;

data test2;
set test2;
by sku;
if first.sku;
run;

~ Sukanya E
SAS Super FREQ
Posts: 8,744

Re: Group information

Hi:
As Scott says, either PROC MEANS or PROC SUMMARY can summarize the data by any combination of CLASS variables.

However, I'm confused by the data. I don't understand how Jan 10, Feb 10 and March 10 are all week number 40. Unless the WEEK variable doesn't have any relevance to the actual DATE variable.

I may have misinterpreted your starting data and your desired results, but it seems to me as though WEEK is irrelevant in this context and the desired report is actually a summary based on CLIENT and SKU.

cynthia
N/A
Posts: 0

Re: Group information

I'm Sorry about the confusion. Data format is DD/MM/YY. In fact week 40 is october 1st, 2nd and 3th

I need to summarize by SKU, client per week
Tks Message was edited by: elilika
N/A
Posts: 0

Re: Group information

The code provided earlier was summerized by SKU, and the output was what you expected. Let me know if that is not the desired result.

~ Sukanya E Message was edited by: Sukanya
PROC Star
Posts: 1,566

Re: Group information

As Scott said, proc SUMMARY does it:

[pre]class CLIENT WEEK SKU;
var VOLUME;
output out=DSOUT sum=;
Ask a Question
Discussion stats
  • 6 replies
  • 145 views
  • 0 likes
  • 4 in conversation