hi friends ,
any body clearify my doute ,
data set " A" have 100 observations(inputdataset), "B" output dataset,
in dataset " A" ,every 5th observation should come to data set "B" ,
let me clearify me?
or more simply:
data b;
set a;
if mod(_n_,5) = 0 then output;
run;
The previous examples read every row then output every 5th.
Fine for a one-off run or a small sample.
This is more efficient technique which only reads every 5th row but it's slightly more code.
data b;
do i = 1 to rows by 5;
set a point=i nobs=rows;
output;
end;
stop;
run;
One more option, if you have SAS/Stat.
this will generate a randon 20% sample
proc surveyselect data=a out=b
rate=0.2;
run;
quit;
And if you have SAS/STAT 13.1 or higher, you can use PROC SURVEYSELECT also to literally select every 5th observation (without any random component):
proc surveyselect data=a out=b
method=sys(start=5) rate=0.2;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: