BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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

mark
1 REPLY 1
deleted_user
Not applicable
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;
cards;
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
;
run;

proc sql;

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

Thanks,
Saurabh.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1175 views
  • 0 likes
  • 1 in conversation