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

Hello, I have a large data set and I want to get random samples with each ID, ACCN, ACCT_CNT, and group Please see the sample below

 

One ID can have multiple ACCN and ACCT_CNT is counts per each ID. 

IDID 2ACCT_CNTGROUP
11231 
212341 
212352 
517891 
517902 
312361 
312372 
312383 
415611D
415622D
415633D
415644D
415655D
619101D
619202D
619303D
619404D
619505D
619606D


I tried proc survey select to get random samples by each ID and acct_cnt but I couldn't figure it out.

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

did you try the 

OUTALL option

includes all observations from the sampling frame in the OUT= output data set. By default, the output data set includes only those units selected for the sample. When you specify the OUTALL option, the output data set includes all observations in the sampling frame along with a variable (Selected) that indicates each observation’s selection status. The value of Selected is 1 for an observation that is selected or 0 for an observation that is not selected. For information about the contents of the output data set, see the section Sample Output Data Set.

The OUTALL option is available for equal probability selection methods (METHOD=SRS, METHOD=URS, METHOD=SYS, METHOD=SEQ, and METHOD=BERNOULLI). and for METHOD=POISSON.

If you specify a sample size of 0 for a stratum, PROC SURVEYSELECT omits this stratum from the sampling frame. By default, PROC SURVEYSELECT also omits this stratum from the output data set when you specify the OUTALL option. You can specify the OUTALL(ZEROSTRATA) option to include strata that have sample sizes of 0 in the output data set. For more information, see the description of the SAMPSIZE= option.

 

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Hi @kpdoe   Have you tried using stratified sampling  in proc survey select?

 

 

 

kpdoe
Calcite | Level 5

I tried but then in the output I would get random samples but not complete. for ex, from the table ID 4 would only one record would get printed. I want to print all  5 obs printed in the random samples from that group.

 

 

IDID 2ACCT_CNTGROUP
11231 
212341 
212352 
517891 
517902 
312361 
312372 
312383 
415611D
415622D
415633D
415644D
415655D
619101D
619202D
619303D
619404D
619505D
619606D

 

novinosrin
Tourmaline | Level 20

did you try the 

OUTALL option

includes all observations from the sampling frame in the OUT= output data set. By default, the output data set includes only those units selected for the sample. When you specify the OUTALL option, the output data set includes all observations in the sampling frame along with a variable (Selected) that indicates each observation’s selection status. The value of Selected is 1 for an observation that is selected or 0 for an observation that is not selected. For information about the contents of the output data set, see the section Sample Output Data Set.

The OUTALL option is available for equal probability selection methods (METHOD=SRS, METHOD=URS, METHOD=SYS, METHOD=SEQ, and METHOD=BERNOULLI). and for METHOD=POISSON.

If you specify a sample size of 0 for a stratum, PROC SURVEYSELECT omits this stratum from the sampling frame. By default, PROC SURVEYSELECT also omits this stratum from the output data set when you specify the OUTALL option. You can specify the OUTALL(ZEROSTRATA) option to include strata that have sample sizes of 0 in the output data set. For more information, see the description of the SAMPSIZE= option.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 773 views
  • 0 likes
  • 2 in conversation