Hi,
I am working with a database in which I want to replace the value of all strings in the first row with "" (missing). I tried to run the following code, hoping that stata would identify all strings values. But string values of different lengths do not seem to be considered of type "string". I could not find the same requests in other discussions.
Any ideas how to correct my code?
foreach v of varlist id - formcasecase_id {
local type: type `v'
display "`v' is of type `type'"
display "First observation of `v': `=`v'[1]'"
if "`type'" == "string"{
replace `v' = "" in 1
}
}
Thank you!
I am working with a database in which I want to replace the value of all strings in the first row with "" (missing). I tried to run the following code, hoping that stata would identify all strings values. But string values of different lengths do not seem to be considered of type "string". I could not find the same requests in other discussions.
Any ideas how to correct my code?
foreach v of varlist id - formcasecase_id {
local type: type `v'
display "`v' is of type `type'"
display "First observation of `v': `=`v'[1]'"
if "`type'" == "string"{
replace `v' = "" in 1
}
}
Thank you!
Comment