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

I have variable size having more than 1000 values. I want to create a group of (low, medium, high) on the basis of size values. so whole size will be divided into 3 groups. top 1 are high then medium and low.

in this example data it is shown that there are 9 values. Top3 are in high group, having values in the middle level 3 values are in medium group then lowest 3 are in low group. So my intention is to create this group variable.  

Size group

10    low

20    low

50    low

50    medium

70   medium

80   Medium

95   high

99   high

99   high

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Are those the only values you'll see in the dataset? Or are there ranges of the variables?

 

One quick way is to use PROC RANK which will use percentiles, ie bottom 1/3 will be low by percentiles, top 1/3 will be high using a percentile. Rank will use a 0/1/2 to create the groups and you can rename them if desired.

 

proc rank data=have out=want groups=3;
var size;
ranks rank_size;
run;

@jazzy wrote:

I have variable size having more than 1000 values. I want to create a group of (low, medium, high) on the basis of size values. so whole size will be divided into 3 groups. top 1 are high then medium and low.

in this example data it is shown that there are 9 values. Top3 are in high group, having values in the middle level 3 values are in medium group then lowest 3 are in low group. So my intention is to create this group variable.  

Size group

10    low

20    low

50    low

50    medium

70   medium

80   Medium

95   high

99   high

99   high


 

View solution in original post

2 REPLIES 2
Reeza
Super User

Are those the only values you'll see in the dataset? Or are there ranges of the variables?

 

One quick way is to use PROC RANK which will use percentiles, ie bottom 1/3 will be low by percentiles, top 1/3 will be high using a percentile. Rank will use a 0/1/2 to create the groups and you can rename them if desired.

 

proc rank data=have out=want groups=3;
var size;
ranks rank_size;
run;

@jazzy wrote:

I have variable size having more than 1000 values. I want to create a group of (low, medium, high) on the basis of size values. so whole size will be divided into 3 groups. top 1 are high then medium and low.

in this example data it is shown that there are 9 values. Top3 are in high group, having values in the middle level 3 values are in medium group then lowest 3 are in low group. So my intention is to create this group variable.  

Size group

10    low

20    low

50    low

50    medium

70   medium

80   Medium

95   high

99   high

99   high


 

jazzy
Calcite | Level 5
Thank. There are ranges of variables.
I think this will work for my requirement.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 7522 views
  • 2 likes
  • 2 in conversation