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
How many data types are there in SAS?
what do the sas log messages "numeric values have been converted to character" mean? : Sas programming
what is data integration? : Sas-di
which date functions advances a date time or date/time value by a given interval? : Sas programming
Explain the use of proc gplot? : sas-grid-administration
Describe the function and utility of the most difficult SAS macro that you have written?
What versions of SAS have you used (on which platforms)?
what are the categories that sas informats are used to the place the data? : Sas-administrator
How can sas program be validated?
Name some categories in sas 9? : sas-grid-administration
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 change analysis in sas di ? : Sas-di
Mention the validation tools used in SAS?
please can you tell me that in companies sas work are doing by through sas coding or sas wizard ??
how can you import .csv file in to sas? : Sas programming