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.
I'm not following your logic. Some sample data and expected output will help illustrate your problem.
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
Look at Proc expand. We don't need actual data, sample data that reflects your situation.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.