Hi,
I have a dataset with the following variables:
- Brand (41 brands in total)
- product identifier (identifies unique product and unique brand)
- Date started
- Date ended
- Brand start
- Brand end
ex:
product identifier brand date started date ended Brand start Brand end
101 A 2001 2002 1990 2010
102 A 2008 2010 1990 2010
I would like to analyze how many different products are produced by a given brand, year by year (generate a new dataset).
My initial idea was to create a duplicate my observations so that I now have a row for each year between brand start and brand end. I then wanted to sum columns X conditional on the brand name, and date started being before the year corresponding to the row, and date ended being after the year corresponding to the row.
product identifier brand date started date ended Brand start Brand end Year X Value of interest
101 A 2001 2002 1990 2010 1990 1 ?
A 1991 0
A 1992 0
...
102 A 2008 2010 1990 2010 1990 1
A 1992 0
Value of interest would be calculated by adding the value in the X column for each row that meet the criteria: for the value of interest, brand has to be A, date started has to be before 1990, date ended has to be after 1990.
I did this without any problems in Excel but I have no idea of how to do it with STATA. Any suggestions?
Thank you very much in advance.
Josh.
Related Posts with Conditional sum on STATA
Reassign variable valuesI would like to record the responses of the adult females (n_female) in the household in sequence i.…
xtcloglog population averaged vs. random effectsHi Statalist, I would like to estimate a complementary loglog model with induvidual effects using S…
Regression for event studyHello, I am analyzing the correlation between market cap and abnormal returns of targeted M&A fi…
mixed not concaveIn order to replicate the problem of not concave, the data is uploaded:https://www.dropbox.com/s/k45…
Showing country-specific treatment effectsHello, I'm currently working with a dataset with individual respondents. In my analysis, I show the…
Subscribe to:
Post Comments (Atom)
0 Response to Conditional sum on STATA
Post a Comment