DATA Step, Macro, Functions and more

Analysis of price change over a period

Reply
Contributor
Posts: 23

Analysis of price change over a period

HI,

 

I am stuck while analysing a data set.

 

i have prices of some models over 4 months.

 

I need a output where i can see the price change & % change in price month wise and overall for each model. 

 

PFA sample data & suggest.

 

your suggestion will be highly appreciated.

 

Thanks

Super User
Posts: 17,819

Re: Analysis of price change over a period

Please post the data into the question directly rather than as an attachment.

 


ramya_sahu wrote:

HI,

 

I am stuck while analysing a data set.

 

i have prices of some models over 4 months.

 

I need a output where i can see the price change & % change in price month wise and overall for each model. 

 

PFA sample data & suggest.

 

your suggestion will be highly appreciated.

 

Thanks


 

Contributor
Posts: 23

Re: Analysis of price change over a period

Model

PriceMonth
15451
25151
33951
45851
55551
64651
74501
84551
96201
104651
16652
24402
35652
44052
54802
65052
74252
85452
94902
104802
15353
24603
34653
45953
55303
65703
75853
85403
95103
105103
15904
25204
35304
45254
55104
64604
75004
83504
94454
104554

 

please consider data

PROC Star
Posts: 7,363

Re: Analysis of price change over a period

[ Edited ]

If you want the output file in the structure you showed, use the same code as I suggested earlier, but transform the results. e.g.

 

proc sort data=have out=need;
  by model month;
run;

data need;
  set need;
  by model;
  change=ifn(first.model,.,price/lag(price)-1);
run;

proc transpose data=need prefix=Price_Month_ out=want (drop=_n:);
  by model;
  id month;
  var price;
run;

proc transpose data=need prefix=Change_Month out=need (drop=_:) ;
  by model;
  id month;
  var change;
run;

data want;
  merge want need;
  by model;
  format Change_Month1-Change_Month4 percent6.2;
run;

Art, CEO, AnalystFinder.com

PROC Star
Posts: 7,363

Re: Analysis of price change over a period

I think that the following will do what you want:

proc sort data=have out=want;
  by model month;
run;

data want;
  set want;
  by model;
  change=ifn(first.model,.,price/lag(price)-1);
run;

Art, CEO, AnalystFinder.com

 

 

Contributor
Posts: 23

Re: Analysis of price change over a period

HI, 

 

i need output like below or better you can suggest;

 

 Price Month wisePrice ChangePercentage change
Month1234 234234
model           
1500400350300 -100-50-50-20%-13%-14%
2           
3           
4           
5           
6           
7           
8           
9           
10           
Super User
Posts: 17,819

Re: Analysis of price change over a period


ramya_sahu wrote:

HI, 

 

i need output like below or better you can suggest;

 

  Price Month wise Price Change Percentage change
Month 1 2 3 4   2 3 4 2 3 4
model                      
1 500 400 350 300   -100 -50 -50 -20% -13% -14%
2                      
3                      
4                      
5                      
6                      
7                      
8                      
9                      
10                      

Are the values in that table made up or should they align somehow with your data posted?

Please make sure they line up, it really helps when trying to determine your logic. 

Ask a Question
Discussion stats
  • 6 replies
  • 152 views
  • 2 likes
  • 3 in conversation