How to select the observations randomly from a SAS dataset
Answer Posted / 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 |
Post New Answer View All Answers
Explain the use of proc print and proc contents?
What is the difference between the proc sql and data step?
Differentiate between ceil and floor functions.
What are the different servers in sas? : sas-grid-administration
what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming
Describe the function and utility of the most difficult SAS macro that you have written?
Difference between SAS STATA & SPSS?
what is SAS OPTIMIZATION?
what are the types of interactive display types? : Sas-bi
What are the limitations for memory allocation for SAS variables
How to specify variables to be processed by the freq procedure?
List out some key concept of SAS
which date function advances a date, time or datetime value by a given interval? : Sas programming
What is factor analysis?
what are the scrubbing procedures in sas? : Sas programming