How to select the observations randomly from a SAS dataset

Answers were Sorted based on User's Feedback



How to select the observations randomly from a SAS dataset..

Answer / srinath

Proc surveyselect;
this gives the random selection of observations.

Is This Answer Correct ?    23 Yes 1 No

How to select the observations randomly from a SAS dataset..

Answer / learner

By using ranuni function. for example you want select 30
percent of data randamly from a data set.

data x;
set y;
if ranuni(100)<.3 ;
run;

here 100 is the seed. the number generated depends on this
seed .

Is This Answer Correct ?    11 Yes 1 No

How to select the observations randomly from a SAS dataset..

Answer / srikanth

you can use the RANUNI function to select observations
randomly.

Ex:-

data test;
input number @@;
cards;
2.1 3.1 4 6 2.2 4.9 4 5 3 3.3 4 5 3 4.3 5 7 3 3 9 11
;

data test1;
set test;
random=ranuni(1);
run;

%let k=10;

PROC SORT DATA=TEST1;
BY random;/*SORT OBSERVATIONS*/
run;

DATA TEST2;
SET TEST2 (DROP=RANDOM);
IF _N_ LE &K;
RUN;

PROC PRINT ;
RUN;

Is This Answer Correct ?    8 Yes 6 No

How to select the observations randomly from a SAS dataset..

Answer / neel

By using the point function

Is This Answer Correct ?    1 Yes 1 No

How to select the observations randomly from a SAS dataset..

Answer / chowdary vamsi

using rununni function generate random sample observations

Is This Answer Correct ?    0 Yes 0 No

How to select the observations randomly from a SAS dataset..

Answer / name is no need

I think by using mod operator we can select the random
observations.
syntax:mod(_n_,number);

Is This Answer Correct ?    5 Yes 6 No

How to select the observations randomly from a SAS dataset..

Answer / ram

by using proc sort.

Is This Answer Correct ?    2 Yes 18 No

Post New Answer

More SAS Interview Questions

Explain translate function?

0 Answers  


How to get part of string form the source string without using sub string function in SAS?

3 Answers  


what can you learn from the sas log when debugging? : Sas programming

0 Answers  


how to assign a macro value to a variable?

8 Answers   CitiGroup,


How to get top scorer student from a class-table having different sections A,B, C & D? Each section having same number of students.

2 Answers  






Give an example where SAS fails to convert character value to numeric value automatically?

0 Answers  


% let A=3+4 what is result

4 Answers   Satyam,


Is it possible to do sorting tranformation in charecter variable??if can tell me one eg..

1 Answers  


What sas features do you use to check errors and data validation?

0 Answers  


How would you include common or reuse code to be processed along with your statements?

5 Answers   PSCI,


how do the in= variables improve the capability of a merge? : Sas programming

0 Answers  


Can we replace a dataset into view?

6 Answers   CliniRx,


Categories