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 are the best practices to process the large data sets in sas programming? : Sas-administrator
What is the difference between %local and %global? : sas-macro
If you have a dataset that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variables?
What is the difference between nodupkey and nodup options?
Describe the ways in which you can create a macro variable?
In SAS explain which statement does not perform automatic conversions in comparisons?
Hi,by usining ptf how we have to combine (likr merge)10 datasets at a time in the oracle database(and write a macro code also)?Like this i have a douts a lot if you dont mind may please send one text mail for me(madhusudhanap16@gmail.com)?
If you could design your ideal job, what would it look like?
How do you add a number to a macro variable? : sas-macro
What do you code to create a macro? : sas-macro
Difference between SAS STATA & SPSS?
How would you define the end of a macro? : sas-macro
Differentiate between sas functions and sas procedures.
what is function of retain statment
AE datasets names? how many types?