BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
6 REPLIES 6
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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
deleted_user
Not applicable
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
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
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
deleted_user
Not applicable
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
ChrisNZ
Tourmaline | Level 20
As Scott said, proc SUMMARY does it:

[pre]class CLIENT WEEK SKU;
var VOLUME;
output out=DSOUT sum=;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 753 views
  • 0 likes
  • 4 in conversation