How to maintain observations using PROC SURVEYSELECT with n=?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 99
Accepted Solution

How to maintain observations using PROC SURVEYSELECT with n=?


Dear all,

Code below,

PROC SURVEYSELECT DATA=WORK.SORTTempTableSorted

OUT=WORK.RANDRandomSampleCAL_OLDFINAL(LABEL="Random sample of WUTEMP.CAL_OLDFINAL")

METHOD=URS

N=20 ;

STRATA branch_code;

ID "Ver Date"n branch_code acct_officer "HUB Cust Id"n "Cust Short Name"n "Sex Code"n Age "Tel No"n "Tel No 2"n "Mobile/Pager No"n "PFS Cust Segment Code"n bdrOpen;

RUN;

Question:

Some observation within a specific "branch_code" is less than 20,

using these code, they output nill.

but what i want is if the no is less than 20, then output all observation.

How can achieve it by modifing codes?

Thanks in advance.

Dawn.


Accepted Solutions
Solution
‎01-06-2013 09:40 PM
Respected Advisor
Posts: 4,659

Re: How to maintain observations using PROC SURVEYSELECT with n=?

Nothing wrong with the NOTES, I get the same with the test above and the output dataset contains all sampling units for those strata.

I checked the documentation back to SAS 9.1.3 and the behaviour for method=URS hasn't changed. Try adding option OUTHITS to your PROC SURVEYSELECT statement. The output dataset should then contain exactly 20 observations for each branch_code stratum.

PG

PG

View solution in original post


All Replies
Respected Advisor
Posts: 4,659

Re: How to maintain observations using PROC SURVEYSELECT with n=?

I guess something went wrong with your test because with method=urs the sampling behaviour of proc surveyselect is exactly what you want. Consider the following test :

proc sort data=sashelp.zipcode out=zipcode; by statecode; run;

proc sql;
select statecode, count(zip) as n
from zipcode
group by statecode;
quit;

proc surveyselect data=zipcode n=10 out=zip10 method=urs;
strata statecode;
id statecode zip;
run;

proc sql;
select statecode, count(zip) as n
from zip10
group by statecode;
quit;

It gives you smaller Ns for some states but no missing values.

PG

PG
Frequent Contributor
Posts: 99

Re: How to maintain observations using PROC SURVEYSELECT with n=?

Dear PG,

     Thx for giving another thought.

     I provide the log as below, can u identify what's wrong, thx.

NOTE: The sample size, 20, is larger than the number of sampling units, 16.

NOTE: The above message was for the following stratum:

      branch_code=AFU.

NOTE: The sample size, 20, is larger than the number of sampling units, 15.

NOTE: The above message was for the following stratum:

      branch_code=BKC.

Result: those with branch_code=AFU and branch_code=BKC will output nill under the above code.

Solution
‎01-06-2013 09:40 PM
Respected Advisor
Posts: 4,659

Re: How to maintain observations using PROC SURVEYSELECT with n=?

Nothing wrong with the NOTES, I get the same with the test above and the output dataset contains all sampling units for those strata.

I checked the documentation back to SAS 9.1.3 and the behaviour for method=URS hasn't changed. Try adding option OUTHITS to your PROC SURVEYSELECT statement. The output dataset should then contain exactly 20 observations for each branch_code stratum.

PG

PG
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 230 views
  • 3 likes
  • 2 in conversation