Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining weekly sales count

Status
Not open for further replies.

jen9814

Technical User
Nov 5, 2002
35
US
I am trying to determine the count of sales by week. I have a sales dataset that has a sent date and a purchase date. Any suggestions?
 
Jen9814,
What determines the sale date. Do you consider the sent date or the purchase date as the basis for the sale count.

Either way why not count the records that have one of your dates filled in. (I presume that the 'sale' information you are looking for is determined by haveing one of those fields filled in.) You will have to assign the records to a week value. You can accomplish this by using the intchk function.
data test;
set your_ds;
week_var = INTCK('WEEK',begin_date,sale_date);
run;
You can use proc sql like this;
proc sql;
create table temp as
select week_var, count(sale_date) as number_of_sales
from test
group by week_var;
quit;

This should give you the number of sales in a given week. Note that the SAS WEEK function uses the number of Sundays in the time frame as the week number.

Klaz
 
How about this little beauty. I tried to do something similar a little while back and created my own format to produce a year/week result from a SAS date.

Proc Format;
Picture yrwk (default=6) '01Jan1980'd - '31Dec2065'd='%Y%0U'
(Datatype=Date);
Run;

Then, in your datastep you use the following statement:-

week = put(purchase_date,yrwk6.);

Then you use this new field for you summarisation.

Enjoy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top