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.
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;
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)
How exactly do I do 3. in SQL? I can just extract based on a list of client numbers in another database?
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;
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;
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!
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.