turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Split height variable

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-14-2014 08:26 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to rfarmenta

05-14-2014 08:58 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to rfarmenta

05-14-2014 08:58 PM

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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to rfarmenta

05-14-2014 09:25 PM

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;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to art297

05-14-2014 09:38 PM

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

PG

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to rfarmenta

05-15-2014 10:25 AM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

05-15-2014 01:34 PM

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.