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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 1101 views
  • 0 likes
  • 1 in conversation