<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: visitnum carry forward locf in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/visitnum-carry-forward-locf/m-p/468322#M119600</link>
    <description>&lt;P&gt;Seems pretty straight forward, what have you tried? Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;BR /&gt;data want;&lt;BR /&gt;  set want;&lt;BR /&gt;  retain lstv;&lt;BR /&gt;  if visit ne "" then lstv=visit;&lt;BR /&gt;  else visit=cats(lstv,"_locf");&lt;BR /&gt;run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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.&amp;nbsp; A simple retain then to populate the previous visit.&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jun 2018 10:58:20 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-06-07T10:58:20Z</dc:date>
    <item>
      <title>visitnum carry forward locf</title>
      <link>https://communities.sas.com/t5/SAS-Programming/visitnum-carry-forward-locf/m-p/468307#M119595</link>
      <description>&lt;P&gt;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:&amp;nbsp; 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.&amp;nbsp;&lt;BR /&gt;data exp;&lt;BR /&gt;length id $10 num 8 visit $30;&lt;BR /&gt;infile datalines dsd truncover ;&lt;BR /&gt;input id $ num visit $;&lt;BR /&gt;datalines;&lt;BR /&gt;0087 ,2,V2 Day 28&lt;BR /&gt;0087 ,3,V3 Day 56&lt;BR /&gt;0088 ,2,V2 Day 28&lt;BR /&gt;0088 ,4,V4 Day 84_EOT_ET&lt;BR /&gt;0097 ,2,V2 Day 28&lt;BR /&gt;0099 ,2,V2 Day 28&lt;BR /&gt;0099 ,4,V4 Day 84_EOT_ET&lt;BR /&gt;0100 ,2,V2 Day 28&lt;BR /&gt;0100 ,3,V3 Day 56&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want bellow the output visitnum had 2 and 3&amp;nbsp; here 3 is carry &lt;SPAN&gt;forward same subj visitnum 4 how to do it&amp;nbsp;&lt;/SPAN&gt;.&lt;BR /&gt;0087,2,V2 Day 28&lt;BR /&gt;0087,3,V3 Day 56&lt;BR /&gt;&lt;STRONG&gt;0087,4,V3 Day 56,locf&lt;/STRONG&gt;&lt;BR /&gt;0088,2,V2 Day 28&lt;BR /&gt;&lt;STRONG&gt;0088,3,V2 Day 28,locf&lt;/STRONG&gt;&lt;BR /&gt;0088,4,V4 Day 84_EOT_ET&lt;BR /&gt;0097,2,V2 Day 28&lt;BR /&gt;&lt;STRONG&gt;0097,3,V2 Day 28,locf&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;0097,4,V2 Day 28,locf&lt;/STRONG&gt;&lt;BR /&gt;0099,2,V2 Day 28&lt;BR /&gt;&lt;STRONG&gt;0099,3,V2 Day 28,locf&lt;/STRONG&gt;&lt;BR /&gt;0099,4,V4 Day 84_EOT_ET&lt;BR /&gt;0100,2,V2 Day 28&lt;BR /&gt;0100,3,V3 Day 56&lt;BR /&gt;0100,3,V3 Day 56&lt;BR /&gt;&lt;STRONG&gt;0100,4,V3 Day 56,locf&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 09:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/visitnum-carry-forward-locf/m-p/468307#M119595</guid>
      <dc:creator>teja5959</dc:creator>
      <dc:date>2018-06-07T09:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: visitnum carry forward locf</title>
      <link>https://communities.sas.com/t5/SAS-Programming/visitnum-carry-forward-locf/m-p/468322#M119600</link>
      <description>&lt;P&gt;Seems pretty straight forward, what have you tried? Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;BR /&gt;data want;&lt;BR /&gt;  set want;&lt;BR /&gt;  retain lstv;&lt;BR /&gt;  if visit ne "" then lstv=visit;&lt;BR /&gt;  else visit=cats(lstv,"_locf");&lt;BR /&gt;run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;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.&amp;nbsp; A simple retain then to populate the previous visit.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 10:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/visitnum-carry-forward-locf/m-p/468322#M119600</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-07T10:58:20Z</dc:date>
    </item>
  </channel>
</rss>

