Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

what are the best practices to process the large data sets in sas programming? : Sas-administrator

958


What is the difference between %local and %global? : sas-macro

1117


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?

1106


What is the difference between nodupkey and nodup options?

970


Describe the ways in which you can create a macro variable?

1033


In SAS explain which statement does not perform automatic conversions in comparisons?

1261


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)?

1626


If you could design your ideal job, what would it look like?

2869


How do you add a number to a macro variable? : sas-macro

950


What do you code to create a macro? : sas-macro

1061


Difference between SAS STATA & SPSS?

1055


How would you define the end of a macro? : sas-macro

1032


Differentiate between sas functions and sas procedures.

1143


what is function of retain statment

1975


AE datasets names? how many types?

2442