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
Mention what is the difference between nodupkey and nodup options?
What is the basic syntax style in SAS?
how can you import .csv file in to sas? : Sas programming
hi all, I need the SAS DI DUMP(A00 260) for attending the certification. if any one have, pls provide it.Please Email to vrpotluri@hotmail.com. Thanks - Ramana
What are the different servers in sas? : sas-grid-administration
How many data types are there in SAS?
for what purpose would you use the retain statement? : Sas programming
how do you debug and test your sas programs? : Sas programming
What is the work of tranwrd function?
what are the new features included in the new version of sas i.e., Sas 9.1.3? : Sas programming
Explain what Proc glm does?
What are the five ways to do a table lookup in sas? : sas-grid-administration
How does SAS handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, PROCs?
what is intially documentation in sas?
Explain input and put function?