GhostRider
GhostRider

Reputation: 2170

Difficulty with creating a new variable in Stata using the subtraction operator

I am a Stata novice.

I am having great difficulty creating this variable:

generate gap= 0.364 * (male − 0.707) − 0.0146 * (FVCpercent  − 66.763) + 0.131 * (age_integer − 67.676) − 0.0814 * (age_gap) + 0.0287 * (avg_fibrosis − 22.147)

male is numeric (male=1, female=0) FVCpercent, age_integer, age_gap and avg_fibrosis are all numeric.

I repeatedly get this error

male−0.707 invalid name

For some reason, if I switch all the "-" operators to "+" it works.

I would be grateful for any input. Many thanks.

Upvotes: 1

Views: 356

Answers (1)

It was a weird error related to the character that you are using. It is somewhat different from -(which is the correct one). I replace them, and now it works.

clear all
input  male FVCpercent age_integer age_gap avg_fibrosis
10 10 10 10 10 10
end

generate gap = 0.364 * (male - 0.707) - 0.0146 * (FVCpercent  - 66.763) + 0.131 * (age_integer - 67.676) - 0.0814 * (age_gap) + 0.0287 * (avg_fibrosis - 22.147)

Upvotes: 3

Related Questions