Dear all,
I turn to you for advice once again, as I am working for the first time on a dataset that is not in a time series (i.e. year and id are unique identifyers). My dataset looks a bit like the following :
id yearClosed tradeRecievables
113 2015 946440
113 2016 1037787
113 2014 6237883
113 2012 10739971
113 2013 8890283
Id = a corporation and there are thousands per sector, etc. What I am trying to do is generate a new variable that is the average of tradeRecievables[_n] - tradeRecievables[_n-1], per id. The different closing years are not equal accross the companies (some start at 2007 for example), so I need to tell Stata to treat the command by the set of yearClosed per id for all the ids available.
Is there a way to do that?
Thank you so much in advance!
Related Posts with Programming a loop for non-time series dataset
Error specifying multiple quantilesI am trying to run quantile regression with clustered standard errors. I would like to run .25, .5 .…
Web scarping errorHello all, I downloaded the command nba2stata to get data from this website to STATA. However when …
Using postfile with xtregHi guys, I would like to perform a regression within a loop and store the results in excel. Ideally…
replacing values of newly generated string variable if old string variable contains certain charactersHello, I have a string variable called relationship that describes the relationship between 2 peopl…
How I can egen a variable to capture the sum value of numbers in the different columnsDear Stata users, I am working on a dataset with many dummy variables. What I want to achieve is eg…
Subscribe to:
Post Comments (Atom)
0 Response to Programming a loop for non-time series dataset
Post a Comment