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 |
If you have a data set that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variable?
If you set a label in the data step and call a proc freq on the data, how do you display the data without the labels and just the variables.
how to change the execute of macro
what are different analysis datasets you created and what are the new variables created
What is the sas data set? : sas-grid-administration
Explain what is the use of proc gplot?
what type of reports you are generating in your company...???
2 Answers GSK GlaxoSmithKline,
what is chi-square test? have you used that?
1 Answers Accenture, Quintiles,
Difference between SAS STATA & SPSS?
Name statements that are execution only.
what is Business Intelligence?
Under what circumstances would you code a SELECT construct instead of IF statements?