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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.