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.
Choosing between OLS , RE, FEHello I am analyzing the effect of LPI on export and import trade ( using panel data) when I ran OLS…
summarizing in StataHi, I´m a rookie in using Stata and I am stuck at this point. I have an issue using the sum function…
putexcel command - errorHi all I have a question about the putexcel command. When I run the code, sometimes I get the foll…
Drop duplicate quarterly datesHi, I am working with a dataset which consisted of monthly obeservations of two variables m1 and m3…
Comparing categorical variables over time in a randomised cluster trialGood morning everyone, hope you're all well - and hope that you can help with some confusion. I hav…
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