Dear members of Statalist,
I am fairly new to Stata and I have been struggling with an issue I believe is related to the "foreach" command. In my dataset, I have a variable (related_diagnosis) which contains various ICD10-codes where I am interested to make a new categorical variable which encodes 1 if there is a value within that variable containing a specific letter ("G"). related_diagnosis is coded as a string variable. The variable contains thousands of observations, and looking for observations containing "G" would take a very long time. I suppose I should use a loop such as "foreach" to simplify this.
I've tried to search for a similar topic without success. If this is answered in another topic, I would be grateful if someone could provide the link discussing this topic.
Best,
Haakon
Related Posts with Using the foreach-command to find a spesific part among hundreds of observations in a string variable.
How to know the sample of countries taken in an analysis!Hi ! This may sound like a silly question. I am working on a panel data with 140 countries. However…
convergence with SEMDear all, I use STATA 15.1 to build a full model with SEM. In the final process, STATA shows me th…
Which regression model i should useHi. i have a data set of firms where i'm trying to see the impact of different innovation strategies…
New on SSC - markupest - module for markup estimation Code: ssc install markupest markupest is a new and comprehensive module for micro- and macro-level …
Pre-Post analysis: How to compare frequencies for each category across rounds?Hi all, I have a panel data of the following form: Code: * Example generated by -dataex-. To inst…
Subscribe to:
Post Comments (Atom)
0 Response to Using the foreach-command to find a spesific part among hundreds of observations in a string variable.
Post a Comment