Monday 12 February 2018

/*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;

2 comments:

  1. /*select every 3rd obs */
    data d2;
    set sashelp.class;
    if mod(_n_,3)=0 then output;
    run;

    ReplyDelete
  2. /*select 1 n last records from a dataset through sql*/
    proc sql;
    /*create table x */
    select * from sashelp.class having monotonic()=min(monotonic()) or
    monotonic()=max(monotonic())-1;
    quit;

    ReplyDelete