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
name some data transformation used in sas di? : Sas-di
What is the different between functions and PROCs that calculate the same simple descriptive statistics?
explain about various caches available in data integrator? : Sas-di
what do the sas log messages "numeric values have been converted to character" mean? : Sas programming
AE datasets names? how many types?
What is the difference between reading data from an external file and reading data from an existing data set?
How sas treats the dsd delimiters?
What would be the result of the following SAS function (given that 31 Dec, 2000 is Sunday)?
what type of graphs we will create(for 2+years candidates)?
what is change analysis in sas di ? : Sas-di
If you were told to create many records from one record, show how you would do this using array and with proc transpose?
how the sas basic syntax style described? : Sas-administrator
What are the new features included in the new version of SAS Programming Language?
what are the types of interactive display types? : Sas-bi
what is intially documentation in sas?