0
votes

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

1 Answers

1
votes

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.