/*LOCF (Last Observations Carry Forward) */
DATA TEST;
INPUT PAT VISIT LABSTD;
CARDS;
101 1 0.1
101 2 0.3
101 3 .
101 5 0.1
101 6 0.9
102 1 0.7
102 2 0.3
102 3 .
102 5 0.4
102 6 0.9
;
Run;
/*locf by lag*/
Data test1;
Set test;
LABSTD1=lag(LABSTD);
/*If LABSTD=. then LABSTD=LABSTD1; */
Run;
DATA TEST;
INPUT PAT VISIT LABSTD;
CARDS;
101 1 0.1
101 2 0.3
101 3 .
101 5 0.1
101 6 0.9
102 1 0.7
102 2 0.3
102 3 .
102 5 0.4
102 6 0.9
;
Run;
/*locf by lag*/
Data test1;
Set test;
LABSTD1=lag(LABSTD);
/*If LABSTD=. then LABSTD=LABSTD1; */
Run;
/*select every 3rd obs */
ReplyDeletedata d2;
set sashelp.class;
if mod(_n_,3)=0 then output;
run;
/*select 1 n last records from a dataset through sql*/
ReplyDeleteproc sql;
/*create table x */
select * from sashelp.class having monotonic()=min(monotonic()) or
monotonic()=max(monotonic())-1;
quit;