Hello world of stats and analysis,
I have dibbled a bit in STATA over my university years but my work has required me to become much more engaged with the software.
I am currently working on a project (using STATA 13.0) trying to determine seasonal sales patterns to implement a sales sampling strategy across multiple provinces in Cambodia.
I have a large dataset with 24 variables and 120,000+ observations. My first step is to manipulate the current dataset to remake sales years based on seasonal patterns in Cambodia. It happens that a sales year makes much more sense from November 1st - October 31st (the following year). The dataset has sales records of every sale done by any supplier based on date (SUPPLIER_ID / DAY / MONTH/ YEAR / SALE_AMOUNT).
I am having problems writing code that would systematically eliminate any sales before November the year that particular supplier joined our records. For example supplier 43 joined in 01/04/2014 and has sales until 01/09/2017. I would like to delete all sales previous to 01/11/2014 for supplier 43, and then do that for all suppliers in my dataset.
I have been fiddling with the bysort function: bysort SPID year month: generate y=1 then replace y=. if SPID==SPID[_n-1] & month>=11. I feel like im close but just missing the code to tell STATA to identify and replace only the first year they joined so that later I can write a code to eliminate all 'missing values'
I hope all that makes sense,
Thank you all for your help!
Related Posts with Problem manipulating large database based on conditional statements to eliminate specific observations
Five Year Average Period. Each Variable?Dear all, I want to create five year average periods for my independent variables (FDI inflows) and…
linking data with a keyHello I need some help linking this data set So the variable taskdefinitionid is the numerical cod…
Looping over two localsHello, I'm endeavoring to loop over two locals. The first local is made up variables consisting of …
Predicting residuals from instrumental regressionModel : ivreghdfe itotf (qt = lagqt lagcfo) cfo, absorb(gvkey fyear) endog(qt) cluster(gvkey) resid …
Using loop to import, edit, then export .csv filesHello, I am importing a large number of .csv files into Stata. Before I can import the files, I nee…
Subscribe to:
Post Comments (Atom)
0 Response to Problem manipulating large database based on conditional statements to eliminate specific observations
Post a Comment