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.
Need to calculate age (in years)Hi All, I hope I explain this clearly and with enough information, please let me know if I can prov…
Restrict household with children age 7-23Hello all, i am currently doing my thesis using the data from IFLS. i want to estimate the effect of…
How to find the level of intangible assets in different years?Good morning everybody. I would like to find the level of intangible assets in different years (simi…
Margins at the median and all the other variables at zero levelHello people, I have run my LOGIT regression and now I want to obtain the marginal effect at the me…
how to solve the problem of stata: error while loading shared libraries: libpng16.so.16: cannot open shared object file in linuxShown as above, I am a non-root user of a linux server, and cannot use sudo in linux server. After i…
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