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
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
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.