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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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