Can anyone help me with how seed works in Stata for drawing sample from multiple data sets?
I have two data sets A and B, each contains 400 observations and each data set is divided into 4 groups (100 observations in each group). I would like to draw 30 observations from each group for each data set and make sure it is reproducible.
I tried two methods:
1. I load data set A, set seed 12345, sample 30, count by(group). Then I load data set B, sample 30, count by(group). At the end of sample data set A and begin of sample data set B, I use command display c(seed) to make sure the seed displayed are the same.
2. I append data set B to data set A (label data set with A and B), then set seed 12345, sample 30, by(group data).
My question is: how come the result sample using these two methods are different? Actually, the result sample for data set A is the same between two methods and for B are different. Can anyone please explain to me how seed works in Stata sampling?
Thank you very much for your help!
Related Posts with Question about using one seed to draw sample from multiple data set.
jackknife loop with wrong number of observationsforvalues i = 1/139 { reg fawtd fdistockgdp if seqnum != `i', robust outreg2 using table, append e…
ARDL lag coefficientsHi everyone or anyone who knows this better than me, I am trying to fit the following short-run equ…
Interpreting a non-linear relationship with predicted values and margins plot I am trying to interpret a non-linear relationship in a fixed effects model. Attached is my Stata …
How to generate a new variable based on existing variablesDear Stata experts, I have a dataset like below. "tiea"=1 means in a given year the company has a c…
Wagstaff concentration Index for binary outcomeHi, I have read in existing literature that if we are dealing with a binary outcome (i.e th individ…
Subscribe to:
Post Comments (Atom)
0 Response to Question about using one seed to draw sample from multiple data set.
Post a Comment