BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Takdir
Obsidian | Level 7

by each year, by each SIC, i want do divide this dataset into 2 dataset of top quartile and bottom quartile based on Qratio.

 

data firm;

    input YEAR SIC Qratio;

    datalines;

2009 1111 1.5
2009 1111 2.5
2009 1111 3.5
2009 1111 4.5
2009 1111 4.5
2009 1111 4.5
2009 1111 4.5
2009 2222 1.7
2009 2222 1.7
2009 2222 1.7
2009 2222 1.7
2009 2222 1.7
2010 1111 2.7
2010 1111 3.7
2010 1111 4.7
2010 1111 5.7
2010 2222 6.7
2010 2222 7.7
2010 2222 8.7
2010 2222 9.7
2010 3333 10.7
2010 3333 11.7
2010 3333 12.7
2010 3333 13.7
2010 4444 14.7
2010 4444 15.7
2010 4444 16.7
2010 4444 17.7
2010 4444 18.7
2010 4444 19.7

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

It's not a one-step process, it takes two steps.

 

PROC RANK with the option GROUPS=4 creates quartiles.

 

Then you take the output data set and split the data into the upper and lower quartiles.

--
Paige Miller

View solution in original post

3 REPLIES 3
Reeza
Super User

Look at PROC RANK which will group your data based on quartiles.

 


@Takdir wrote:

by each year, by each SIC, i want do divide this dataset into 2 dataset of top quartile and bottom quartile based on Qratio.

 

data firm;

    input YEAR SIC Qratio;

    datalines;

2009 1111 1.5
2009 1111 2.5
2009 1111 3.5
2009 1111 4.5
2009 1111 4.5
2009 1111 4.5
2009 1111 4.5
2009 2222 1.7
2009 2222 1.7
2009 2222 1.7
2009 2222 1.7
2009 2222 1.7
2010 1111 2.7
2010 1111 3.7
2010 1111 4.7
2010 1111 5.7
2010 2222 6.7
2010 2222 7.7
2010 2222 8.7
2010 2222 9.7
2010 3333 10.7
2010 3333 11.7
2010 3333 12.7
2010 3333 13.7
2010 4444 14.7
2010 4444 15.7
2010 4444 16.7
2010 4444 17.7
2010 4444 18.7
2010 4444 19.7

 


 

Takdir
Obsidian | Level 7

I looked at the Proc Rank. But I am still confused how to create different dataset for each group since I am really new to this coding. Could you help me with some codes ? 🙂

PaigeMiller
Diamond | Level 26

It's not a one-step process, it takes two steps.

 

PROC RANK with the option GROUPS=4 creates quartiles.

 

Then you take the output data set and split the data into the upper and lower quartiles.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 834 views
  • 0 likes
  • 3 in conversation