0

I'm having some trouble with syntax. Here's the directions for the problem:

"Let's examine how random measurement error in Y affects the results. Create a new dependent variable (noisy-y, Y) that is equal to the fraction of children sick plus noise. The noise will take the form of rnormal(0,0.3) in Stata. First type "set seed 11111" into Stata and then sort the data by household, "sort folio". You will want to use the generate command to create the new variable. Regress the new variable (noisy-y) on treatment (X, "treated").

This is what I have in my do file:

set seed 11111
sort folio 
generate noisy-y = (frac_children_sick + rnormal(0,0.3))

and I'm returned with "error: invalid syntax".

Any help would be greatly appreciated!

1 Answer 1

1

Stata variable names must start with a Unicode letter or _, and the remaining characters may be Unicode letters, _, or Unicode number digits. Examples of Unicode letters are "a", "Z", and "é"; examples of Unicode digits are 0, 1, and 9.

Your variable name contains a hyphen, so Stata complains:

. gen noisy_y = rnormal(0,0.3)

. gen noisy-y = rnormal(0,0.3)
invalid syntax
r(198);

If you click on the error code, it reads

These errors are often, but not always, due to typographical errors.... In giving the message "invalid syntax", Stata is not helpful.

Type help varname to learn more.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.