Hello everyone, I'm new to Stata programing and need some help.
I'm currently cleaning and adjusting some variables hat I'll need to use on my models and one of them is the number of members living in the interviwed household.
I criated a ID variable (idom) to give each household a specific number based on serials, controls, etc.
This count variable already exists for some years, but not for the entire datased. I'am basically trying to recreate it.
Here is a sample of what I have:
- idom is the ID that I created for each member of an specific household and v4741 is the variable with how many members this household has. I want to recreate the variable v4741 counting how many times this specific ID appears.
Obs. idom v4741
----------------
7593667. 400713 6
7593668. 400713 6
7593669. 400713 6
7593670. 400713 6
7593671. 400713 6
7593672. 400713 6
----------------
7593673. 400714 4
7593674. 400714 4
7593675. 400714 4
7593676. 400714 4
----------------
7593677. 400716 4
7593678. 400716 4
7593679. 400716 4
7593680. 400716 4
----------------
7593681. 400717 5
7593682. 400717 5
7593683. 400717 5
7593684. 400717 5
7593685. 400717 5
----------------
7593686. 400718 3
7593687. 400718 3
7593688. 400718 3
----------------
7593689. 400719 2
7593690. 400719 2
----------------
7593691. 400720 5
7593692. 400720 5
7593693. 400720 5
7593694. 400720 5
7593695. 400720 5
Since my dataset has more than 7.5 million observations I think it's better to handle this on Stata, but this is something that I could make on Excel with a 'countifs' formula.
Any tips to share?
Thank you!
Related Posts with Create a counting variable
How to save HR and 95%CI and P-value from Loops of cox regression from ten exposures on same outcome in a separate file (excel or dta)Hi, I am recently working on a project that requires me to calculate the HRs and 95%CI and p-value f…
model command in endogeneity testHi. I'm using Stat 13 and need to have endogeneity test. My model is as below. I wonder whether the …
Control variablesHi, I have a question in regards control variables. I am making a diff-in-diff model to measure the…
How to set monthly panel data in stata ?Hello guys, i have monthly panel data of import and want to do regression but the problem is i dont …
Test for assumptions of OLS and FEHi, I am making a diff-in-diff regression for the top ESG companies relative to the bottom ESG comp…
Subscribe to:
Post Comments (Atom)
0 Response to Create a counting variable
Post a Comment