samedi 17 octobre 2020

SAS - Randomly select 10 subjects and retain all of their observations

I am stuck with a the following problem in SAS. I have a dataset of this format: enter image description here

The dataet consists of 500ids with different number of observations per id. What I am trying to do is to randomly select 5id's and at the same time retain all of their observations. I built a random generator in the first place saving a vector with 10 numbers in the interval [1,500]. however it became clumpsy when I tried to use this vector in order to select the ids correspoding to the vector with the random numbers. To be more clear, I want my net result to be a dataset which includes all observations correspoding to id 1,10,43, 22, 67, or any other sequence of 5 numbers.

Thanks a lot in advance! Any tip will be more than appreciated!




Aucun commentaire:

Enregistrer un commentaire