BookmarkSubscribeRSS Feed
rjrolls
Calcite | Level 5

Hi All,

 

I'm wanting to categorise a continuous variable into groups based on criteria set from values in other variables. 

 

Briefly, I have Body Mass Index data (BMI) for individuals identified by sex and age (e.g. Female, 14; Male, 17). I've got percentile data of the BMI for each sex and age combination (e.g. 5th percentile, 85th percentile, 95th percentile), which has been merged with the BMI data. I'm wanting to create a new variable (named 'BMI_category') that categorises each individual into a weight range class (Underweight, Healthy, Overweight, and Obese) based on BMI percentile data. The first few lines of the dataset are shown in the image attached:

 

Using SAS 9.4, I want to assign each individual to a BMI_category based on the individuals BMI with reference to BMI percentile data. For example, a female, aged 14 would be classified as Underweight if their BMI was less than the 5th percentile (_5th, being 15.5), Healthy is between 5th and 85th percentile (_5th - _85th), Overweight when BMI is between 85-9th percentile (_85th - _95th), and Obese when BMI is equal or greater than the 95th percentile (_95th).

 

So for the first individual in the example dataset, they would be classified based on their BMI (21.2) as being 'Healthy' because their BMI is between the 5th percentile (15.5) and the 85th percentile (23.3). 

 

So far I've used the following code to categorise each individual:

 

proc format;
value f_BMI_category
0 = 'Underweight'
1 = 'Healthy'
2 = 'Overweight'
3 = 'Obese';
run;

 

data BMImerged3;
set BMImerged2;
where Sex = 'Female' and Age = 14;
if BMI <15.5 then BMI_category = 0;
if BMI >=15.5 and BMI <23.3 then BMI_category = 1;
if BMI >=23.3 and BMI <27.1 then BMI_category = 2;
if BMI >=27.1 then BMI_category = 3;
format BMI_category f_BMI_category.;
run;

 

This code above works fine for the BMI percentile data for Females aged 14 years, because I have set the categorisation manually for the BMI ranges for each category (e.g. <15.5, >=15.5, >23.3 etc). To speed up the process, how can I set the thresholds for categorisation for one variable (e.g. BMI) based on values from other variables in the same dataset (e.g. _5th percentile values)?

 

Thanks in advance.

1 REPLY 1
ballardw
Super User

Please see this link:  https://www.cdc.gov/nccdphp/dnpao/growthcharts/resources/sas.htm

For code and rational of BMI for age percentile assignments.

 

Then assign the category based on the actual BMI percentile. Your age range is a tad "wide" for precision. I hope you have date of birth and date of measurement to get a matching interval from the CDC charts.

 

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2074 views
  • 0 likes
  • 2 in conversation