I would like to obtain a nationally representative sample from a (non representative) survey data set thereby using every individual from the given survey data set. To do so I am creating a 100% random sample with the corresponding weights by using gsample 100 [aw=weight], percent. I am not expanding the data by using the weights first and then drawing a random sample with other commands (e.g. sample) since the data set that I start with is already quite big. The problem is that I am not getting the same sample every time I draw the sample. I tried to set the seed at various positions, at the beginning of the do-file or right before the gsample command. I also tried to sort the data according to a unique identifier right before drawing the sample and also setting the seed right before that. But nothing has helped to have the same random sample when I draw the sample again and again. Any help would be appreciated. I cannot post my code before using gsample command since it is quite long, but some commands involve sorting the data.
Related Posts with Set Seed Random Sample
datetime 2012-04-24 08:00:01Hello, I am trying to import "2012-04-24 08:00:01" as a datetime, but it shows as "2012-04-24 07:59…
Calculate number of "common friends" in the past five yearsDear fellow Statalisters, For a large panel data set on alliances, I want to calculate the number o…
Filtering quality variablesI am having s panel data on macro variables for 72 countries (I. e. ;gdp, inflation etc) and a conti…
Problem - Use 2 datasets in one do file (single run)Hi all ! I need help on stata I am trying to create one do file in Stata (mandatory) using 2 diff…
Panel Regression with a Moderator Variable*Please forgive my lack of Stata/Statistics knowledge or basic questions, I'm fairly new to Stata an…
Subscribe to:
Post Comments (Atom)
0 Response to Set Seed Random Sample
Post a Comment