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
Related Posts with Making new variable from first letter of string variable
Help with Bar graph of three categorical variables and ratesDear Stata Community, I am working with a dataset which has three categorical variables, whether pr…
Compare quantile ranges between STATA and QgisI have what I assume is a fairly simple problem to solve. I am using Qgis to create maps using quant…
Diff-in-diff collinearity problem with leads and lagsDear Statlist users, This is my first post so I hope I've done everything according to Statalist pr…
simple linear regression with changehello, I would like to investigate whether sectors that invest relatively more in computer capital …
Easier and faster way to get casewise statistics using tabstat?In my data set, I compare analytes analyzed in a test analyzer (X) to those analyzed in a reference …
Subscribe to:
Post Comments (Atom)
0 Response to Making new variable from first letter of string variable
Post a Comment