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
Describe a time when you were really stuck on a problem and how you solved it?
what is sas database server? : Sas-di
How substr function works in sas?
List down the reasons for choosing sas over other data analytics tools.
How long can a macro variable be? A token? : sas-macro
What is the difference between INPUT and INFILE ?
Explain the use of proc print and proc contents?
What is the purpose of _character_ and _numeric_?
What is factor analysis?
explain the key concept of sas? : Sas-administrator
What are the 3 components in sas programming?
What are the five ways to do a table lookup in sas? : sas-grid-administration
how does sas handle missing values in functions? : Sas programming
what is sas metadata server? : Sas-di
I have 3 years of work experience at a startup and recently got certified in Data Science with SAS. I need to know how to get into the analytics industry