How to select the observations randomly from a SAS dataset
Answers were Sorted based on User's Feedback
Answer / srinath
Proc surveyselect;
this gives the random selection of observations.
| Is This Answer Correct ? | 23 Yes | 1 No |
Answer / learner
By using ranuni function. for example you want select 30
percent of data randamly from a data set.
data x;
set y;
if ranuni(100)<.3 ;
run;
here 100 is the seed. the number generated depends on this
seed .
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / 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 |
Answer / chowdary vamsi
using rununni function generate random sample observations
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / name is no need
I think by using mod operator we can select the random
observations.
syntax:mod(_n_,number);
| Is This Answer Correct ? | 5 Yes | 6 No |
What is the size of PDV?
What type of tables you are using in YOUR reporting..???
2 Answers GSK GlaxoSmithKline,
i have multiple .csv files in a unix directory. every file is having variable names as header.even for empty file also. suppose take 3 files a.csv b.csv c.csv a.csv contains data as name;age,salary; raja;34;4000; ravi;33;5000; kumar;25;3000; b.csv contains data as name;age,salary; ajay;40;4500; and c.csv contains name;age,salary; (only headers) Now i want to import and append all these files in to a single dataset. i tried infile statement with *.csv to import all at a time. but i m not getting correct data. please help me . its urgent. thank you in advance
how do you test for missing values? : Sas programming
how can you get the single data set from the library(which has the number of data sets)?
3 Answers Accenture, Deloitte,
%STPbegin;%STPEND; ERROR: No logical assign for filename _WEBOUT. WARNING: No body file. HTML output will not be created. unable to fix it.plz help
What is the difference between %local and %global?
What are some problems you might encounter in processing missing values? In Data steps? Arithmetic? Comparisons? Functions? Classifying data?
how the sas basic syntax style described? : Sas-administrator
what are all the default values getting in PROC MEANS...???
What do you know about sas and what we do? : sas-grid-administration
explain the proc in sas? : Sas-administrator