<>
Note also that for numeric variables a < . and !missing(a) are
equivalent.
!= . catches .a to .z too.
Nick
[email protected]
Joseph Coveney
John Bunge wrote:
i have 3 variables called v1d, v2d, v3d which all equal to .
moreover i have 3 variables a1, a2, a3 which equal to . or some
numerical
value
i want
replace v1d = 1 if a1 ~=.
replace v2d = 1 if a2 ~=.
replace v3d = 1 if a3 ~=.
how can i do this in 1 command? with forvalue?
------------------------------------------------------------------------
------
--
Not sure about a single line of code, but the following should work.
forvalues i = 1/3 {
replace v`i'd = 1 if !missing(a`i')
}
If you're using v?d variables as flags for nonmissing values in the
corresponding a? variables, then be aware that v?d will always test
True,
because they'll be either . or 1, both of which are nonzero. If you're
using
v?d variables as nonmissing-value indicator variable for a?, then the
following would be better.
forvalues i = 1/3 {
replace v`i'd = !missing(a`i')
}
In this case, v?d will be 1 (True) if a? is not missing, and 0 (False)
otherwise.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/