Syntax diagram for generate allows for specification of desired variable storage type preceding the variable name.
such as
A colleague of mine has just shown me the situation where the syntax was written incorrectly, but Stata didn't complain:
I initially suspected some rudimentary flexibility in the syntax, such as permitted by the format command (which allows swapping the order of the format and variable name). But it turns out that Stata completely ignores the type specification in such a case. Moreover, type can be numeric and still cause no syntax error:
I think it is a syntax bug and the correct behavior should be to report an error of either "invalid type" as according to syntax c is not a Stata type, or "invalid varname" as str10 can't be a variable name because it is reserved.
Interestingly the qualifier if can also be inserted before the equal sign, and it does work!
Best, Sergiy Radyakin
such as
Code:
generate double price=cost/volume
Code:
generate c str10="test"
Code:
generate d double="test"
Interestingly the qualifier if can also be inserted before the equal sign, and it does work!
Code:
. sysuse auto (1978 Automobile Data) . generate t if mpg>22="test" (48 missing values generated) . generate t2 double if mpg>22="test" (48 missing values generated)