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