Skip to main content

Research Repository

Advanced Search

Speaking Stata: Loops in parallel

Cox, Nicholas J.

Speaking Stata: Loops in parallel Thumbnail


Authors



Abstract

This column is a tutorial discussing looping in parallel using foreach and forvalues. Such looping may use not only local macros defined for the purpose but also other devices, including the gettoken command and ways to increment and decrement other macros and to evaluate other expressions. The main idea is that a set of loops in parallel is essentially one loop with two or more sets of parallel actions. Examples cover looping over integers with a required specific display format, generating new variables and defining variable labels at the same time, binning variables as desired, and putting skewness results in new variables. The last example includes some historical comments on the tangled literature on skewness measures using medians and quantiles.

Citation

Cox, N. J. (2021). Speaking Stata: Loops in parallel. The Stata Journal, 21(4), https://doi.org/10.1177/1536867x211063415

Journal Article Type Article
Online Publication Date Jan 6, 2022
Publication Date 2021
Deposit Date Mar 8, 2022
Publicly Available Date Mar 8, 2022
Journal The Stata Journal: Promoting communications on statistics and Stata
Print ISSN 1536-867X
Electronic ISSN 1536-8734
Publisher SAGE Publications
Peer Reviewed Peer Reviewed
Volume 21
Issue 4
DOI https://doi.org/10.1177/1536867x211063415

Files

Published Journal Article (284 Kb)
PDF

Publisher Licence URL
http://creativecommons.org/licenses/by/4.0/

Copyright Statement
https://creativecommons.org/licenses/by/4.0/This article is distributed under the terms of the Creative Commons Attribution 4.0 License (https://creativecommons.org/licenses/by/4.0/) which permits any use, reproduction and distribution of the work without further permission provided the original work is attributed as specified on the SAGE and Open Access pages (https://us.sagepub.com/en-us/nam/open-access-at-sage).





You might also like



Downloadable Citations