Hello,
I have a weird little problem in Stata 14 that I have been able to work around, but I'm confused as to why it's not working in the way I expect it to.
I have a dataset that has labels rather than numeric values for responses. I am trying to replace them with values and then destring the varaibles.
As shown below, my "replace if" command matches the value as reported in the codebook exactly, but then makes no changes.

I think it must have to do something with the slash in the label. Below is a reproducible example:
After inputting the data, run the following command to illustrate the problem:
Any ideas? Thanks in advance!
I have a weird little problem in Stata 14 that I have been able to work around, but I'm confused as to why it's not working in the way I expect it to.
I have a dataset that has labels rather than numeric values for responses. I am trying to replace them with values and then destring the varaibles.
As shown below, my "replace if" command matches the value as reported in the codebook exactly, but then makes no changes.
I think it must have to do something with the slash in the label. Below is a reproducible example:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str25 human1 "1" "Refused/ Skipped" "1" "Incorrect/ Does not know" "Refused/ Skipped" end
Code:
codebook human1 replace human1 = "0" if human1 == "Incorrect/ Does not know"
Comment