Hello,
I am looking to code a foreach loop that completes a ustrlen() command for all string values of a variable, not just the distinct values. I have been able to get some success with the following code, but as expected of the levelsof command it only completes the ustrlen() command to only distinct string values.
. levelsof variable, local(levels)
. foreach v of local levels {
2. display ((ustrlen("`v'")-3)/4)+1
3. }
I have been referencing the related documentation and this page, https://www.stata.com/support/faqs/d...-with-foreach/, but have not been able to find success with Method 1. Is there a command similar to levelsof that would allow me to complete this loop?
Thanks very much in advance!
Related Posts with Creating a foreach loop for all string values of a variable.
Changing the graph label while using the "catplot" commandHello! to make clear what my problem is I use the data "sysuse auto". To show you my problem I use t…
generate all Root MSE from regressionHey there, I have run 722 regressions with my data set for each firm year by using: bysort variable…
cmp with panel dataDavid Roodman. Excuse me, Sir, a quick question. How can I use cmp command to run a two-way fixed mo…
Correct usage of xtabond2Hi all, I am writing about the correct usage of xtabond2, performing System GMM in STATA. My data a…
How to adjust for matched factors using Conditional Logistic RegressionHello. I hope you can help. I am trying to build a conditional logistic regression model to analyse…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a foreach loop for all string values of a variable.
Post a Comment