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
What is the difference between input and infile statement?
What are pdv and it functions?
What is the use of PROC gplot?
How we can call macros with in data step? : sas-macro
What are symget and symput? : sas-macro
Describe a time when you were really stuck on a problem and how you solved it?
How to limit decimal places for the variable using proc means?
how does sas handle missing values in a merge? : Sas programming
What are the difficulties u faced while doing vital signs table or dataset?
Explain by-group processing?
Difference between SAS STATA & SPSS?
What are the difference between the sas data step and sas procs?
Why and when do you use proc sql?
how does sas handle missing values in sort order? : Sas programming
What is PROC in SAS?