I'm quite new to Stata (version 17.0) and I'm having some trouble implementing a loop for some basic calculations.
I have variables spanning from 1952-2021 for 143 countries, measured quarterly (i.e. 4 variables for each year). They are currently named in the general format "WUI_1952q1", "WUI_1952q2", "WUI_1952q3", "WUI_1952q4".. etc., for each year, with q1-q4 representing the quarters. Example:
Array
I would like to create variables that are the average of the 4 quarterly variables for each year. I tried creating a loop (only for 4 years to begin with):
Code:
local years 1952 1953 1954 1955 foreach i of local years { mean WUI_'i'q1 WUI_'i'q2 WUI_'i'q3 WUI_q4 }
Thank you in advance!
0 Response to Loop over quarterly variables to find yearly means
Post a Comment