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