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 we can create a FLAG datasets? Ex:-ID age_group no_persons 1 to 10 10 to 20 3 11 to 20 21 to 30 7 21 to 3o 31 to 40 5
What are the statements in proc sql?
Differentiate between proc means and proc summary.
What is interleaving in SAS?
Mention the difference between ceil and floor functions in sas?
How do you delete duplicate observations in sas?
describe how to adjust the performance of data integrator? : Sas-di
How does SAS handle missing values in: assignment statements, functions, a merge, an update, sort order, formats, PROCs?
what is change analysis in sas di ? : Sas-di
what is the purpose of _error_? : Sas programming
how could you generate test data with no input data? : Sas programming
what is snowflake schema? : Sas-di
List down the reasons for choosing sas over other data analytics tools.
What is the use of the %include statement?
What would you change about your job?