BookmarkSubscribeRSS Feed
ksmith133333333
Calcite | Level 5

Hi first time poster, let me know if i need to provide more details.

 

I am attempting to use proc rank to create quintiles for 4 different variables.

 

My data is firm-year observations from 2010-2017. I have four variables i need to separately assign quintiles to.

 

First: Is there a way to have the proc rank consider the year in assigning the quintiles? So it calculates a 2010 set of quintiles and assigns those for the 2010 firm-years, 2011, etc.?

 

Second: Is there a way to have proc rank ignore missing values in creating the quintiles?

 

{
data WORK.MERGERS101;
infile datalines dsd truncover;
input EIN:BEST12. NAME:$35. FISYR:BEST12. relativeequity:32. revenueconcentration:32. adminratio:32. operatingmargin:32. dissolver:32.;
format EIN BEST12. FISYR BEST12.;
datalines;
990107223 ACADEMY OF THE PACIFIC 2012 1.3208732899 0.312010507 0.1667243535 -0.005034895 1
980365458 MOBILE MEMBER CARE TEAM 2016 1.3077040195 0.4397492632 . -0.126948843 1
990297201 Elementary School Center Hawaii 2010 293.79565217 0 . -13.73478261 1
990345193 Moolelo Performing Arts Company 2015 0.3496993545 0.5470906723 . -2.045450526 1
20481994 Warde Health Center Inc 2014 0.0657027419 0.9282159016 0.1512901232 0.0301761733 1
;;;;
}

2 REPLIES 2
mkeintz
PROC Star

Are your data already sorted by year?   For instance below is dataset sashelp.cars already sorted by ORIGIN (ASIA EUROPE USA).  You can use PROC RANK with a BY statements for all the variables of interest.

proc sort data=sashelp.cars out=have;
  by origin;
run;
proc rank data=have out=want   groups=5 ;
  by origin;
  var    Horsepower          Invoice          Length          MSRP          Weight;
  ranks  Horsepower_quintile Invoice_quintile Length_quintile MSRP_quintile Weight_quintile;
run;

For your dataset, just substitute YEAR for origin and your variables for horsepower--weight.   But remember the quintile variables will be valued at 0 through 4, not 1 through 5.  You may want to run a subsequent data step to add 1 to the quintile variables

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ksmith133333333
Calcite | Level 5

It's currently sorted by ein but I can sort it by year. I'll give this a try!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 402 views
  • 0 likes
  • 2 in conversation