Hello
I have 92 funds in my database. they are sorted by PCSSP_median
. I want to split them in two group (46 low_median and 46 high median). I write this but it does not make equal division
proc rank data=PCSSP_sort out=want groups=2;
var PCSSP_median;
ranks deciles;
run;
thanks
PROC RANK will not make groups of equal size when there are ties in the data. So, if you still want equal sizes, you'd have to write code yourself to split up the ties, some into group 1 and some into group 2.
Crude:
Proc sort data=pcssp_sort; by pcssp_median; run; data want; set pcssp_sort; group= (_n_ le 92)+1; run;
Assigns group 1 for smaller values, 2 for larger. May have same value of pcssp_median in both groups depending on where ties in your data occur.
data want;;
set PCSSP_sort nobs=_nobs;
RANK = 1 - ( _n_ < (_nobs/2));
run;
Quick brute force method above.
NOBS captures the number of observations in the dataset.
NOBS/2 is the middle.
0 => low_median
1 => high_median
If you want it split by the median, PROC RANK is correct.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.