BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GKati
Pyrite | Level 9

Hello,

 

I have a large balanced panel of clients (each client is present in each period). I would like to take a random sample by randomly picking the client and keeping information for all years for that client. 

 

What's the easiest way to do this?

 

K. 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Actually, there is a simpler way to do this using surveyselect. The trick is to do cluster sampling using the client as the cluster:

 

data panel;
do clientID = 1 to 20;
    do period = 1 to 10;
        value + 1;
        output;
        end;
    end;
run;

proc surveyselect data=panel out=panelSample sampsize=10 seed=868585;
samplingunit clientID;
run;
PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

1) Create a list of all the clients (proc SQL)

2) select a sample of clients (proc surveyselect)

3) extract all data for those sample clients (proc SQL)

PG
GKati
Pyrite | Level 9

How exactly do I do 3. in SQL? I can just extract based on a list of client numbers in another database?

 

 

PGStats
Opal | Level 21

Assuming that step 2 results in a table called sampleClients, do something like :

 

proc sql;
create table samplePanel as
select * 
from myPanelData
where clientId in (select clientID from sampleClients);
quit;
PG
PGStats
Opal | Level 21

Actually, there is a simpler way to do this using surveyselect. The trick is to do cluster sampling using the client as the cluster:

 

data panel;
do clientID = 1 to 20;
    do period = 1 to 10;
        value + 1;
        output;
        end;
    end;
run;

proc surveyselect data=panel out=panelSample sampsize=10 seed=868585;
samplingunit clientID;
run;
PG

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2256 views
  • 4 likes
  • 2 in conversation