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
Event study moving average outside event windowThe following panel data provides information about the firm event PERMCO_ED which is unique. DATE i…
control row / colum percent display in svy jackknifewhen i do this: svy jackknife, subpop (if charflag==2 & SCHLEV_3CAT==2 & teach_pe_di==2 ): …
How to find variable1 that contain words like "apple" or "pear" with keywords typea... and replace them with the text "selected fruit"?Hi all. How to find variable1 that contain words like "apple" or "pear" or "orange" with keywords t…
Interpetation of pstestCan anyone help me how to interpret psmatch2 and pstest? I wanted to do probit model ATE test using …
Making loops to create 2 groups of variablesHello all, I have data that is set out with columns divided into Sex; then Labour Force Status (8 c…
Subscribe to:
Post Comments (Atom)
0 Response to Conditional sum on STATA
Post a Comment