turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- proc surveyselect

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-16-2016 08:23 AM

Hi

How can I get the proc survey select to randomly pick cases based upon the criteria that the sum of the variable income should not exceed 0.7 of the (sum of income of selection/ income for total sample)

Accepted Solutions

Solution

11-17-2016
09:18 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kiteulf

11-17-2016 05:01 AM

How about this one:

```
proc sql noprint;
select sum(air)*0.7 into : sum
from sashelp.air;
quit;
data have;
set sashelp.air;
rand=rand('uniform');
run;
proc sort data=have;
by rand;
run;
data want;
set have;
temp+air;
if temp lt ∑
run;
```

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kiteulf

11-16-2016 09:25 AM

You are looking for variables selection method. Check SELECT= option of MODEL statement.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kiteulf

11-16-2016 09:29 AM

Sorry. Ignore my last post. wrong post at wrong place. Can you post an example to explain what you require ?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kiteulf

11-16-2016 11:31 AM

Please provide the version of SAS you are using. There may be options to help with this but they may be version dependent.

Precalculate what 0.7 of the income for the total sample would be: Example: Suppose the Total income in your set is 1000000, available from many procs in different ways: means, summary, univariate or freq to name a few.

Then the target you are looking for is I think 0.7 * 1000000 or 700000.

Use 700000 as the SAMPSIZE with your Income variable as the Size variable.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ballardw

11-16-2016 02:48 PM

The Size variable in proc SurveySelect is for PPS sampling. PPS means Probability (of selection) Proportional to Size. Use a Size variable only if sampling with PPS.

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kiteulf

11-16-2016 02:54 PM

Do you want a fixed sample size with at most 70% of incomes, or do you want to randomly pick sampling units until the income reaches 70% of incomes?

PG

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to PGStats

11-17-2016 02:26 AM

The latter!

Solution

11-17-2016
09:18 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Kiteulf

11-17-2016 05:01 AM

How about this one:

```
proc sql noprint;
select sum(air)*0.7 into : sum
from sashelp.air;
quit;
data have;
set sashelp.air;
rand=rand('uniform');
run;
proc sort data=have;
by rand;
run;
data want;
set have;
temp+air;
if temp lt ∑
run;
```