Help using Base SAS procedures

Multiple Ifs

Not applicable
Posts: 0

Multiple Ifs

Hello ,

I'm stuck in the SAS code.I have sorted the data by the date of sale of product over two week time and there are 180 observations and i want to find revenues for the two weeks time , a breakdown of revenues over two weeks time.There are two models of the laptop sold - say A and B and price of A and B are $ 10 and $ 20 respectively.

How do i produce this breakdown for both weeks of sale of the two laptops.

sincere regards

Not applicable
Posts: 0

Re: Multiple Ifs

Posted in reply to deleted_user
Hi Mark,

I am providing you the sample code for what you require. I hope thats what you require as an answer.
Keep in mind the "Week" function in the code will give you the week number starting from 1st week of the year i.e. the values will vary from 1 to 52.

Just try understanding the code. If you are new to proc sql, then you can go through the some basic concepts of the same, but the query is as simple as a SQL statement.

data test;
input date ddmmyy10. laptop_mod: $2. revenue;
10/03/2009 A 1000
11/03/2009 A 3000
12/03/2009 B 2000
12/03/2009 A 5000
13/03/2009 A 4000
14/03/2009 B 10000
15/03/2009 B 5500
16/03/2009 B 4000

proc sql;

select week(date) as Week, laptop_mod,
sum(revenue) as revenue
from test
group by 1,2

Ask a Question
Discussion stats
  • 1 reply
  • 1 in conversation