mercredi 13 février 2019

How to sample an item from a variable in Stata

I have a huge panel dataset

year id var
2003 513 5
2004 513 10
2003 517 5
2004 517 12
...

for which I want to randomly sample some people (by "id"). ID range has gaps in positive natural numbers (min. 513, max. 287321, but there are some panel dropouts, i.e. 514, 515, 516). I know the code in R, e.g. sample(id, 1) but have no clue what it looks like in Stata.

Thank you very much for your support.




Aucun commentaire:

Enregistrer un commentaire