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

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)

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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;

View solution in original post

7 REPLIES 7
Ksharp
Super User
You are looking for variables selection method.
Check SELECT= option of MODEL statement.


Ksharp
Super User
Sorry. Ignore my last post. wrong post at wrong place.

Can you post an example to explain what you require ?

ballardw
Super User

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.

 

 

PGStats
Opal | Level 21

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
PGStats
Opal | Level 21

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
Kiteulf
Quartz | Level 8

The latter!

Ksharp
Super User

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1124 views
  • 1 like
  • 4 in conversation