Help using Base SAS procedures

baseline, previous value and blank values

Reply
Super Contributor
Posts: 301

baseline, previous value and blank values

Hi everyone,

I have the next dataset:

subjid cpevent  text     value

100 screening  weight 40

100 day1         weight  .

100 day1         pulse   .

and I want to get:

100 day1  weight  40

100  day1  pulse  .

I mean, recording only the previous value when baseline (day1) is missing, (weigth 40), but keeping the missing value of baseline

if not previous value are recording (pulse dont have screening record, then I leave blank ).

Cheers,

V

Respected Advisor
Posts: 3,124

Re: baseline, previous value and blank values

If I understand you correctly,

data have;

infile cards truncover;

input (subjid cpevent text) (:$10.) value;

cards;

100 screening weight 40

100 day1 weight .

100 day1 pulse .

;

data want (drop=_w);

set have;

retain _w;

by subjid;

if first.subjid and cpevent='screening' then _w=value;

if value=. and text='weight' then value=_w;

if cpevent ne 'screening' then output;

run;

proc print;run;

Regards,

Haikuo

Super User
Posts: 9,681

Re: baseline, previous value and blank values

Not understand what you mean.

data have;
infile cards truncover;
input (subjid cpevent text) (:$10.) value;
cards;
100 screening weight 40
100 day1 weight .
100 day1 pulse .
;
run;
data want(where=(cpevent='day1'));
 set have;
 lag_value=lag(value);
 if subjid eq lag(subjid) and cpevent='day1' and missing(value) then  value=lag_value;
 drop lag_value;
run;

 

Ksharp

Ask a Question
Discussion stats
  • 2 replies
  • 217 views
  • 0 likes
  • 3 in conversation