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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6704 views
  • 2 likes
  • 2 in conversation