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.
merging multiple excel file from a folder using key variable household id and monthI have many excel files in a folder and each data file contains variable VDS_ID and SUR_MON_YR. I wa…
Mean of a variable by multiple variables in the same tableHi. In my data there are 20 variables (var1- var20) which are deciles created based on different fa…
Do the regression for only one company each and saving them to an excel/doc (ASDOC)Hi everybody, I do have a panel dataset where every company has a unique ID (-company-) and their r…
causal effect in panel dataHi there, I am struggling to understand something relating to causal effects with panel data. I ha…
ivreghdfeHello all, i try to do an iv regression with fixed effetcs (industry and year) and want to cluster …
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