Hi I have the following string variables: 
Which have the following data: 0 or 1 or Null

I have encoded it:
encode thromboc_aspirin, gen(thromboc_aspirin_n)

I then generated a tab code for thromboc_aspirin_n

I would like to generate a new column with the aim of incorporating only those in thromboc_aspirin_n == 1
code used:
generate VTE_ChemProphylaxis = 0
replace VTE_ChemProphylaxis = 1 if thromboc_aspirin_n == 1

And instead of having just 180,034 values replaced - STATA replaces all the values therefore STATA says 1.1-6.991 real changes made
I do not understand what I am doing wrong and why isn't stata just replacing the 180,034 values that contain a 1 in my thromboc_aspirin_n variable

Which have the following data: 0 or 1 or Null
I have encoded it:
encode thromboc_aspirin, gen(thromboc_aspirin_n)
I then generated a tab code for thromboc_aspirin_n
I would like to generate a new column with the aim of incorporating only those in thromboc_aspirin_n == 1
code used:
generate VTE_ChemProphylaxis = 0
replace VTE_ChemProphylaxis = 1 if thromboc_aspirin_n == 1
And instead of having just 180,034 values replaced - STATA replaces all the values therefore STATA says 1.1-6.991 real changes made
I do not understand what I am doing wrong and why isn't stata just replacing the 180,034 values that contain a 1 in my thromboc_aspirin_n variable
Comment