I am fairly new to STATA, and need to create a moving average for my data. (I cannot use tsset for this data). I am trying to do something like:
gen ma = education if year==19301 + education if year==19302 + education if var==19303 + education if year==19304 / 4
(So i have four years of data I need to find the average of)
I have 40 years of data, and I don't mind if I set up the moving average equation 40 times, but I can't get any form of equation to work.
I am doing a moving average of education by year. How can I do this? Thanks!
Related Posts with gen mean with if statements
creating a count variable for multiple entries per yearI have a pannel dataset that is organized by country, code, year, and Disaster type. the disaster va…
Can I create a new variable based on data labelsGood day. I am trying to replicate the results of a journal article. I have a dataset from the surv…
Observations and data pointsHello, I'm often reading that people report the number of observations and data points. I know where…
Illustrative table of percentages to read in WordDear Statalist, I would like to create a table of publication quality summary percentages. The col…
Calculating LiquidityDear Professor Attaullah, I am using Stata 14. The data type of my research is panel data (unbalanc…
Subscribe to:
Post Comments (Atom)
0 Response to gen mean with if statements
Post a Comment