## Split height variable

Solved
Regular Contributor
Posts: 150

# Split height variable

I am using the CDC BRFSS data and for some reason they report height as a three digit value with feet first then inches, so 511 would be 5ft, 11 inches. I need to calculate BMI because their BMI variable is also calculated a little weird. Is there a way to split the height variable into two variables, one for feet and one for inches. Once I do that I want to multiply the feet by twelve to convert to inches and add that to the inches variable to create a height in inches variable. Any help would be greatly appreciated. Mostly I am stuck splitting up height and inches. Thank you!

Accepted Solutions
Solution
‎05-14-2014 08:58 PM
Posts: 1,270

## Re: Split height variable

Try this.

data have;

input height;

datalines;

511

509

510

601

410

500

;

data want(drop=h);

set have;

h=put(height,3.);

feet=input(substr(h,1,1),1.);

inch=input(substr(h,2,3),2.);

height_inch=feet*12+inch;

run;

All Replies
Solution
‎05-14-2014 08:58 PM
Posts: 1,270

## Re: Split height variable

Try this.

data have;

input height;

datalines;

511

509

510

601

410

500

;

data want(drop=h);

set have;

h=put(height,3.);

feet=input(substr(h,1,1),1.);

inch=input(substr(h,2,3),2.);

height_inch=feet*12+inch;

run;

PROC Star
Posts: 8,164

## Re: Split height variable

Since you only want to convert height into inches you could just use:

data want;

set have;

height=(12*int(height/100))+height-100*int(height/100);

run;

Posts: 5,535

## Re: Split height variable

Or INCHES = floor(height/100)*12 + mod(height, 100);

PG
Super User
Posts: 13,566

## Re: Split height variable

I'm not sure which BRFSS data set you may be referencing but you need to check the data layout. There will be a BMI value, which may have an implied decimal point as well as other BMI related variables.

For 2012 I would look for a variable _BMI5. Other years the number of digits and implied decimal locations have changed. Really, look at the documentation for the specific year.

If you are looking at the actual height and weight question values you have a mixture of metric, preceded by 9 since 2005 where 9150 would mean a height of 150cm, and englis values plus codes that indicate the question was not answered to exclude. The CDC calculated BMI variable takes that into account.

I've been working with BRFSS data since 1998.

Regular Contributor
Posts: 150

## Re: Split height variable

Thank you all for your responses, I was able to get it to work based on the information above.

ballardw-I am using BRFSS 2012 and did actually see the _BMI5 variable. I don't like the way they calculated BMI with values in the thousands. We are assigning a subset of the BRFSS data to students to learn some basic analysis on a project and they are used to seeing BMI with a range of 15-45. We want them to calculate BMI on their own. I actually deleted all of the metric values  from the data. I had just never seen a dataset with a variable set up like the height variable. Thanks again.

🔒 This topic is solved and locked.