BookmarkSubscribeRSS Feed
Kyojik
Obsidian | Level 7

Hello Everyone here. It's my first day to show up here with a problem.
I have made some deciles (10 groups) into my data using following procedures;

proc rank data=mydata.descriptive out=results group=10 ties=low;
by year month;
var CR;
ranks CRRank;
run;

 

Next i calculated their median values by follwoing codes:

proc summary median data=results;
var BM Prc ;
by CRRANK;
output out=Desc n=ht_n median=ht_median std=ht_sd; run;

 

Problem;

 I wanna calculate these median for var = BM and PRC for next period (t+1). I have year and month variables in my data and portfolios are made every month. so for portfolio made in january i want to calculate median of BM from its february value. and then i want to make mean of these median values in each group. may be using something like this.

 

proc summary mean data=results;
var BM Prc ;
by CRRANK;
output out=Desc n=ht_n mean=ht_median std=ht_sd; run;.

 

I will be grateful if you can make some suggestions.
Thanks a lot.

3 REPLIES 3
Reeza
Super User

I'm not following your logic. Some sample data and expected output will help illustrate your problem. 

Kyojik
Obsidian | Level 7

Yes unfortunately its hard to follow because of my bad instructions.
I have no idea how to put data here its really big in many GB.
I thought about another thing. Creating one month lead of my variables (BM Prc). Deciles  are already there. I can make median of that.
by using following codes.
proc summary median data=results;
var BM Prc ;
by CRRANK;
output out=Desc n=ht_n median=ht_median std=ht_sd; run;
now I have only one issue left. how can I take mean of all these medians in each group ? for each variable (BM, PRC)?
proc means;
var BM PRC;
BY CRRANK; run;
The issue is I donot know how can I export above median results into one sas table with lead values. so that I can use these codes to get mean.
does this make any sense?
Thanks for your help

Reeza
Super User

Look at Proc expand. We don't need actual data, sample data that reflects your situation. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 3 replies
  • 751 views
  • 0 likes
  • 2 in conversation