Hi,
I want to compute the average of a variable (teamsize) for observations within a specific time period. I have a date variable formatted as such that I would like to use. Specifically, I have data on companies and their teams at different points in time. I want to calculate the average team size for a specific company within a given time period, always between the current date and 365 days prior to the observation.
. bysort company: egen mean(teamsize) if inrange()
is my best guess (sorry, new to stata and related programs in general!). I do not know how to specify inrange so that it takes the average of all observations with a date (variable is DATE, formatted as %td) in the range of the observation date and the 365 previous days. For example, if the teamsize was 55 on June 1st 2011, I want to create variable with a mean that takes into account all teamsizes from June 1st 2010 to June 1st 2011, including the team size of June 1st 2011.
It would be awesome if someone could help me out!
Best,
Julian
Related Posts with Taking the average of observations within a specific date range
Newey-West HAC standard errors smaller than regress, robust onesHi all, I am running an ARDL model in the form: Code: reg y l.y x1 l.x1 x2 l.x2 After the esti…
FrequencyHi everyone, I want to calculate the cumulative frequency of firms which have different identifiers …
Question for logistic regression analysisGreetings, If i have an ordinal dependend variable , which is a 5 scale likert skala and i want to …
Newey-West HAC standard errors smalle than robust onesHi all, I am running an ARDL model in the form: Code: reg y l.y x1 l.x1 x2 l.x2 After the esti…
Program to calculate a percentile and rank by percentile and a factorI have a dataset that looks like this, 2 observations per id: id observation birth year diabetes …
Subscribe to:
Post Comments (Atom)
0 Response to Taking the average of observations within a specific date range
Post a Comment