Although the -replace- command is fairly intuitive, it is sometimes a bit tricky.
Specifically, say I have a dataset as the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(y x1 x2) 5 . . 12 123 32 32 113 1 end
Code:
replace x1=5 & x2=5 if missing(x1)
Code:
replace x1=5 if missing(x1) replace x2=5 if x1==5
- Why can replace not be used for multiple replacements at once as above?
- What can be done about the fact that if two replacements are to be made using the same condition (missing(x1) in the case above), and if they cannot be done simultaneously, how can one account for the fact that the second replacement can only be identified using a condition that is not unique for the replacement (if x1==5)?
CS
0 Response to Replacing multiple values, with the same condition
Post a Comment