Dear All,
I am working with firm level data. I want to generate a variable lsales = ln(sales) and want to replace the values in lsales as missing if the values in the variable lsales are higher than mean+3*standard deviation. While doing so, I want the summary stat of lsales by grouping state and sector and if the observation of lsales is more than 1000 in the individual group (state-sector) then find the outlier and replace it as missing. If the number of observation is less than 1000 in any of the group (state-sector) then I want to group lsales by the state only and find out the summary stat and replace the outlier with missing values. Please suggest to me how should I code this, as I am unable to visualise the loop for the condition.
Thanks
Prakash
Related Posts with Generating variable and replacing the outlier as missing based on grouping and condition
How margins handles the atmeans optionAsking my students to use the margins command after mlogit for computing marginal effects (using dyd…
Need help with destring/encode variable without changing name of the variableIs it possible to destring/encode a variable from string to numeric without changing the variable na…
-list- all variables but selected ones?I'm wondering if there is a way to -list- all variables excluding those that I select. Let's say, I …
Parallel trend assumption in Diff and Diff methodHi, Currently, I am working with CPS monthly microdata from https://ceprdata.org/cps-uniform-dat.../…
egen mean_var = mean(var), by(xx & xx)Hi How do I generate a mean variable sorted by both year and origin? I want to generate the mean v…
Subscribe to:
Post Comments (Atom)
0 Response to Generating variable and replacing the outlier as missing based on grouping and condition
Post a Comment