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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.