BookmarkSubscribeRSS Feed
teja5959
Fluorite | Level 6

if subject had VISITNUM=4 as early termination (ET) visit and no Visit 3 record then re-assign ET visit to the closest post baseline planned visit and keep the reported data as for analysis as well:  Visit 2/Day 28 (24-32 Days), Visit 3/Day 56 (52-60 Days), Visit 4/Day 84 (80-88 Days). If ET visit is mapped to other than Visit 4 then value is carried forward to Visit 4. 
data exp;
length id $10 num 8 visit $30;
infile datalines dsd truncover ;
input id $ num visit $;
datalines;
0087 ,2,V2 Day 28
0087 ,3,V3 Day 56
0088 ,2,V2 Day 28
0088 ,4,V4 Day 84_EOT_ET
0097 ,2,V2 Day 28
0099 ,2,V2 Day 28
0099 ,4,V4 Day 84_EOT_ET
0100 ,2,V2 Day 28
0100 ,3,V3 Day 56
;
run;

 

i want bellow the output visitnum had 2 and 3  here 3 is carry forward same subj visitnum 4 how to do it .
0087,2,V2 Day 28
0087,3,V3 Day 56
0087,4,V3 Day 56,locf
0088,2,V2 Day 28
0088,3,V2 Day 28,locf
0088,4,V4 Day 84_EOT_ET
0097,2,V2 Day 28
0097,3,V2 Day 28,locf
0097,4,V2 Day 28,locf
0099,2,V2 Day 28
0099,3,V2 Day 28,locf
0099,4,V4 Day 84_EOT_ET
0100,2,V2 Day 28
0100,3,V3 Day 56
0100,3,V3 Day 56
0100,4,V3 Day 56,locf

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Seems pretty straight forward, what have you tried? Something like:

proc sort data=have out=subj nodupkey;
  by id;
run;
data subj;
  set subj;
  do num=2 to 4;
    output;
  end;
run;
proc sql;
  create table want as 
  select coalesce(a.id,b.id) as id, 
         coalesce(a.num.num) as num,
         a.visit
  from    have a
  full join subj
  on     a.id=b.id
  and    a.numb=b.num;
quit;
data want;
set want;
retain lstv;
if visit ne "" then lstv=visit;
else visit=cats(lstv,"_locf");
run;

This will expand your data with the missing rows, so every subject will then have the 2,3,4 rows, but visit will be missing from those merged in.  A simple retain then to populate the previous visit.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1 reply
  • 673 views
  • 0 likes
  • 2 in conversation