Hi guys,
I am having problems with providing a reproducible sample for my dataset.
I have a variable 'Firmsize' which groups observations based on the size of a firm. Now what i want is to get a specific number of random observations from each Firmsize-group. This does work (see the syntaxes below). But every time i run the syntaxes anew, i get different sample-observations, even though i have set the seed in the beginning of the sequence. I have tried a few different possibilities, like setting the seed before every sample-syntax, but these didn't work either. Have you guys got a suggestion on how to get a reproducible sample-dataset for this block of code?
Code:
sort Firmsize
set seed 6500
sample 395 if Firmsize==1, count by(ICMW)
sample 348 if Firmsize==2, count by(ICMW)
sample 295 if Firmsize==3, count by(ICMW)
sample 257 if Firmsize==4, count by(ICMW)
sample 212 if Firmsize==5, count by(ICMW)
sample 185 if Firmsize==6, count by(ICMW)
sample 150 if Firmsize==7, count by(ICMW)
sample 134 if Firmsize==8, count by(ICMW)
sample 103 if Firmsize==9, count by(ICMW)
sample 69 if Firmsize==10, count by(ICMW)
Thanks in advance!
Greetings,
Max
Related Posts with Getting reproducible sample-observations
Help with xtdcce2, missing a lot of observationsDear community, I have encountered an issue with xtdcce2 (xtdcce2 4 - 08.02.2023). I have a balance…
IV strength for two endogenous varsDear all, Greetings. I meet the below problems and hope someone could give me hints. Thank you very…
foreach, forvalues loopCan I use loop command about these? recode v11 (1/9=1) (else =.), generate(hmember_1) recode v14 (1…
Category omitted from fixed effect when running regressionI am having a confusing problem -- when I ran my code last week, everything was normal. Now, not so …
Opening Excel file exported by etableIn the example below, when I click results.xlsx, the file tries (and fails) to open using my browser…
Subscribe to:
Post Comments (Atom)
0 Response to Getting reproducible sample-observations
Post a Comment