07-26-2011 12:55 PM
I have a sample with one dependent dummary variable y (0, 1). The data has been sorted.
Now the question is how I can get easily get a summary (e.g. mean, freq) for the top 5%, 10%, 15%, 20%, 25%, ... 95% sample. I hope there is a way to do this easily, rather than use separate steps to produce the results. Any procedure to do this, PROC UNIVARIATE, PROC FREQ, PROC MEANS?
07-26-2011 01:00 PM
You have to tell us more. If you really do only have one dv, and it IS binary, I would think that just proc freq would provide everything that you need. If it is more complex, proc rank might be what you are looking for.
07-26-2011 01:27 PM
If the variable only has 2 levels it cannot be divided into 20 groups.
If you have a continuous variable then PROC RANK will divide the data into 20 groups and you can summarize using the GROUP as a class variable..
proc rank data=sashelp.heart out=g groups=20;
proc means data=g;
07-26-2011 01:42 PM
Sorry that I did not explain clearly.
What I want is to get the descriptive statistics for the top 5% data, top10% data, top 15%... Here, the data have been sorted in a proper order. The descriptive statistics are just for a single variable (which is a dummy type y=0 or 1).
07-26-2011 03:06 PM
and you may want to look into insight. If you license it, you can activate it by either runing the word insight from the command line, or running the command DM "insight";
I have found it to be an invaluable way to see both the statistics, and graphical representations, of one's data.
08-02-2011 11:59 PM
data test; do index=1 to 100; y=int(ranuni(-1)*2); output; end; run; proc sort data=test ; by descending index; run; %let dsid=%sysfunc(open(test)); %let nobs=%sysfunc(attrn(&dsid,nobs)); %let dsid=%sysfunc(close(&dsid)); %let want_percent=.2; %let want_top=%sysevalf(&nobs*&want_percent,integer); %put _user_; proc means data=test(obs=&want_top) nway noprint; var y; output out=want mean= sum=/autoname; run;