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


Please Help Members By Posting Answers For Below Questions

name some data transformation used in sas di? : Sas-di

757


What is the different between functions and PROCs that calculate the same simple descriptive statistics?

1555


explain about various caches available in data integrator? : Sas-di

819


what do the sas log messages "numeric values have been converted to character" mean? : Sas programming

804


AE datasets names? how many types?

2283


What is the difference between reading data from an external file and reading data from an existing data set?

945


How sas treats the dsd delimiters?

980


What would be the result of the following SAS function (given that 31 Dec, 2000 is Sunday)?

947


what type of graphs we will create(for 2+years candidates)?

2107


what is change analysis in sas di ? : Sas-di

825


If you were told to create many records from one record, show how you would do this using array and with proc transpose?

1194


how the sas basic syntax style described? : Sas-administrator

831


What are the new features included in the new version of SAS Programming Language?

980


what are the types of interactive display types? : Sas-bi

870


what is intially documentation in sas?

4666