BookmarkSubscribeRSS Feed
michtka
Fluorite | Level 6

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

2 REPLIES 2
Haikuo
Onyx | Level 15

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

Ksharp
Super User

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

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 751 views
  • 0 likes
  • 3 in conversation