Hi Statalist,
Thanks for being a great forum which already has helped a lot!
I'm new here, quite fresh to STATA and trying to organize a data file this summer for cancer epidemiology research.
In my data file, I have a string variable "Diagnoses" for ICD-codes for various diseases, where the ICD-codes for cancer starts with the letter "C".
I would like to make STATA select all the cancer diagnoses into a separate variable, and have based on a previous thread tried the command
gen Cancer =.
replace Cancer = 1 if word(Diagnoses,1),"C"
but get the error message "type mismatch" here.
When changing to
gen Cancer=""
replace Cancer = 1 if word(Diagnoses,1),"C"
the same error message pops up so not sure if the mismatch is from Diagnoses being a string variable. Maybe I'm doing something else wrong?
Would be thankful for any advice on how to go around this.
Best,
Mary
0 Response to Making new variable from first letter of string variable
Post a Comment