Random sample in repeated measures dataset

Accepted Solution Solved
Reply
Occasional Contributor ajb
Occasional Contributor
Posts: 18
Accepted Solution

Random sample in repeated measures dataset

ID VISITRACE        SEX   VAR1  VAR2  VAR 3
111        NHB    M     3      2       5
112        NHB    M     4      5       3
113        NHB    M     5      6       3
131        NHW   F      7      6       9
132        NHW   F      6      9       3
141        MA      F      4      8        3
151        NHB    M     9      4        8
152        NHB    M     3      3        4
161        NHB    F      2      2        7
171        NHB    M     3      7        4
191        NHW   F      2      9        8
192        NHW   F      8      2        3

My data looks like this and I want to randomly select on observation per id to make a non-repeated measures dataset. How would I do this?

Thanks in advance


Accepted Solutions
Solution
‎07-27-2015 11:23 PM
Respected Advisor
Posts: 4,814

Re: Random sample in repeated measures dataset

The simplest way is with surveyselect:

*option nonotes;

proc surveyselect data=have out=want sampsize=1;

strata id;

run;

*option notes;

You can use option NONOTES to avoid the notes about selecting all units for IDs with a single obs.

PG

PG

View solution in original post


All Replies
Solution
‎07-27-2015 11:23 PM
Respected Advisor
Posts: 4,814

Re: Random sample in repeated measures dataset

The simplest way is with surveyselect:

*option nonotes;

proc surveyselect data=have out=want sampsize=1;

strata id;

run;

*option notes;

You can use option NONOTES to avoid the notes about selecting all units for IDs with a single obs.

PG

PG
Occasional Contributor ajb
Occasional Contributor
Posts: 18

Re: Random sample in repeated measures dataset

Thanks so much!!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 223 views
  • 0 likes
  • 2 in conversation