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
Re-arrange variablesDear all, I have 30 variables in different columns. Now I want Stata to generate one new variable w…
What is the correct way to use double-clustering in reghdfe?Hi all, I have a panel data set and I believe that correlations appear in two dimensions with both …
Potential Stata (MLwiN/Estout) bug - Output of Odds Ratios' Significance Levels Hi all, I think I may have inadvertently stumbled upon a bug after using the runmlwin command for …
Mauchly's test of sphericity commandI am trying to test the assumption of sphericity for the purpose of running a repeated measures ANOV…
Count model with data panel ( poisson)Hi, I'm new here (and new to stata/statistical analysis) i need help with a count model with data pa…
Subscribe to:
Post Comments (Atom)
0 Response to Making new variable from first letter of string variable
Post a Comment