BookmarkSubscribeRSS Feed
PunkinSAS08
Fluorite | Level 6

Hi all,

 

I am completing an assignment that involves constructing new variables in my code I am supposed to: 

1. create a formula for BMI

2. compute a Categorical BMI variable in which 1=normal (<25) , 2=overweight (25 to <30) and 3=obese

3. three piecewise variables for the BMI intervals as defined in the Categorical BMI.

 

My question is, does my code satisfy the piecewise variables? In our lecture, there are a lot of long and drawn out ways to create piecewise variables but I want to ensure this is being done correctly for analysis. Here is my code: 

proc format;
value BMIcatf 1='normal' 2='overweight' 3= 'obese';
run;
 
data final;
set totalcohort;
 
weight_kg = (weight / 2.205);
height_m = (height * 0.0254);
 
 
 
BMI = (weight_kg) / (height_m **2); *should we have to square the value for correct BMI?*;
if BMI >=19;
 
if BMI <25 then BMIcat = 1;
else if BMI  >= 25 and BMI < 30 then BMIcat = 2;
else  BMIcat = 3;
 
 
 
BMI1 = BMI < 25;
BMI2 = BMI >= 25 and BMI <30;
BMI3 = BMI >=30;
 
waist_hip_ratio = (waist / hip);
 
meanSBP = (bp_1s + bp_2s) / 2;
 
log_glyhb = log(glyhb);
 
if gender = 'male' then male =1;
else male = 0;
 
format BMIcat BMIcatf.;
 
run;
2 REPLIES 2
Rick_SAS
SAS Super FREQ

> 3. three piecewise variables for the BMI intervals 

 

You have constructed one categorical variable (BMIcat), which has the values 1,2,3.

You have created three binary indicator variables (often called "dummy variables"), which you have named BMI1, BMI2, and BMI3.

 

I don't know how your instructor defines a "piecewise variable." If you use that term to mean a binary indicator variable, then this looks fine. If it means something else, we need to know the definition.

 

I would delete the line 

if BMI >=19;

unless you purposely want to exclude underweight people.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 587 views
  • 0 likes
  • 3 in conversation