Hi everyone,
I am trying to list the string values of two varlists (med_other_ind* and med_name*) with the coherent results next to each other, if the first variable contains specific pieces of text ("vit", "tilskud", "osteo" or "forebyg"). I have 20 coherent varlists, and I could do like this:
list med_other_ind1 med_name1 if strpos(med_other_ind1, "vit") | ///
strpos(med_other_ind1, "tilskud") | strpos(med_other_ind1, "osteo") | ///
strpos(med_other_ind1, "forebyg")
list med_other_ind2 med_name2 if strpos(med_other_ind2, "vit") | ///
strpos(med_other_ind2, "tilskud") | strpos(med_other_ind2, "osteo") | ///
strpos(med_other_ind2, "forebyg")
and so on with 20 repetitions in total.
But there must be an easier or smarter way to do it :-)
I have tried with both foreach and forvalues commands, but I only know how to incorporate one of the varlists into the commands. Then I do not get the coherent results as I do with the many commands described above - I get all results from both in a big mess or en error in STATA, eg.
forvalues med_other_ind = 1/20 {
list `med_other_ind' if strpos(`x', "vit") | strpos(`x', "tilskud") ///
| strpos(`x', "osteo") | strpos(`x', "forebyg")
}
I know that x is not defined, but I don't know how to do it.
So please, can anybody help me? Thank you in advance!
Regards, Thomas Prior
Related Posts with List string values of multiple varlists
Referencing local variable in nested foreach var of varlistHi, I would like to do something which I believe is fairly simple, but I can't get the syntax corre…
How do I obtain prevalence ratios using the logistic command?I am using the "logistic" command to estimate a binary outcome (yes/no response, cross-sectional sur…
Rounding the coefficientsDear Researchers, I am sorry, my question may sound silly, but I searched for the answer and the an…
how to assess the effects of confounders in an associationHi everyone I am trying to answer a question if there is a causal effect association between two va…
Hazard as a Propensity Score for Matching - Propensity Score Matching with Time-Dependent CovariatesHello, I am trying to create a matched sample using hazard ratios by observation by id. I am conduct…
Subscribe to:
Post Comments (Atom)
0 Response to List string values of multiple varlists
Post a Comment