I have a dataset that lists all products sold in a one year period in two stores. The quantity sold is aggregated on a monthly basis. A product is normally observed many times. I want to drop all observations of products that are only sold in one of the stores. I only want to keep product_ID's that are sold in both stores. When it was sold is not a matter.
My key variables are month, product_ID, dummy variable Store.
If would be very happy if someone could help me.
Example data:
Month | Product_ID | Store
------------------------------------
1 | 1000 | 0
1 | 1000 | 0
2 | 1001 | 0
7 | 1002 | 0
8 | 1002 | 0
1 | 1000 | 1
1 | 1003 | 1
5 | 1001 | 1
5 | 1003 | 1
If this was my enitre data set I would like to drop all observartions of product_ID 1002 and 1003
Related Posts with Keep only matching values
Query in STATAHi, I have values in my variable (tax_threshold) with many "0" values. I want to replace all the "0…
Merge data1 to data2 between certain datesDear Stata Users, I need to merge data1 to data2 such that data1 is merged to data2 between two dat…
Is there an alternative to gen and egen that will save as double if the number is large?Yesterday I realized that I have to set type to double before doing "gen" for large numeric variable…
Finding out the reason for collinearityThis sounds very dumb actually. But I tried to control for treatment type (T1, T2, and T3) in the re…
How to estimate prevalences of an indicator over the years?Dear Statalist, My dataset presents the prevalence of a given indicator over 11 years (2007 to 2017…
Subscribe to:
Post Comments (Atom)
0 Response to Keep only matching values
Post a Comment