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.
Competing risk modelling and predicting modellingDear colleagues, I got some questions about my statistical analysis on the project measuring about m…
xtreg: Panels are not nested within clustersHi, Stata forum, I am running firm level regression using one country panel data. For firm: xtset …
Problem with Merger commandHi everyone! I Have a problem with the command merge because I need to merge two-panel datasets that…
mcaplot - resize markers by weight/massHi everyone! I have several mcaplots with 20+ variables, and I would like them to be represented by…
HELP with Stata GraphicsDear Statalisty, I am really struggling with generating graphs in Stata. For the dataset below (whi…
Subscribe to:
Post Comments (Atom)
0 Response to Creating a foreach loop for all string values of a variable.
Post a Comment