<?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: locf CODE CONFIRMATION in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723452#M80249</link>
    <description>&lt;P&gt;This simplified code does what I think you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input RANDOMNO Visit Value;
datalines;
1 0 1
1 1 5
1 2 .
1 3 7
1 4 .
1 5 1
2 0 3
2 1 .
2 2 .
2 3 4
2 4 5
2 5 .
3 0 .
3 1 .
3 2 6
3 3 .
3 4 8
3 5 0
;

proc sort data=have;
by RANDOMNO Visit;
run;

data want;
set have;
by randomno;
length DTYPE $15;
retain vlocf;
if first.RANDOMNO then vlocf = .;
vlocf = coalesce(value,vlocf);
if value = . then DTYPE = "LOCF";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 04 Mar 2021 13:46:51 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-03-04T13:46:51Z</dc:date>
    <item>
      <title>locf CODE CONFIRMATION</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723428#M80246</link>
      <description>&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new X&lt;BR /&gt;input RANDOMNO Visit Value X&lt;BR /&gt;DATALINESX&lt;BR /&gt;1 0 1&lt;BR /&gt;1 1 5&lt;BR /&gt;1 2 .&lt;BR /&gt;1 3 7&lt;BR /&gt;1 4 .&lt;BR /&gt;1 5 1&lt;BR /&gt;2 0 3&lt;BR /&gt;2 1 .&lt;BR /&gt;2 2 .&lt;BR /&gt;2 3 4&lt;BR /&gt;2 4 5&lt;BR /&gt;2 5 .&lt;BR /&gt;3 0 .&lt;BR /&gt;3 1 .&lt;BR /&gt;3 2 6&lt;BR /&gt;3 3 .&lt;BR /&gt;3 4 8&lt;BR /&gt;3 5 0&lt;BR /&gt;X&lt;BR /&gt;RUNX&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Proc sort data= new X&lt;/P&gt;&lt;P&gt;By RANDOMNO Visit X&lt;/P&gt;&lt;P&gt;Run X&lt;BR /&gt;DATA LOCFX&lt;BR /&gt;LENGTH DTYPE $15X&lt;BR /&gt;RETAIN retain X&lt;BR /&gt;SET new X&lt;BR /&gt;BY RANDOMNO Visit X&lt;/P&gt;&lt;P&gt;IF FIRST.RANDOMNO and &lt;FONT color="#FF0000"&gt;Visit=0&lt;/FONT&gt; THEN retain=. X&lt;BR /&gt;IF Value NE . and Visit^=0 THEN retain=Value X&lt;BR /&gt;IF Value=. THEN DO X&lt;BR /&gt;VLOCF=retain X&lt;BR /&gt;DTYPE='LOCF' X&lt;BR /&gt;END X&lt;BR /&gt;ELSE VLOCF=Value X&lt;BR /&gt;&lt;BR /&gt;RUN X&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;REPLACED SEMICOLE WITH X AS SAS ASK TO REMOVE TO DO THIS BEFORE POSTING&lt;/P&gt;&lt;P&gt;----------------------------------------------------------&lt;/P&gt;&lt;P&gt;Above code I am using to do LOCF. it is giving me a correct result for this data. It may be not correct for large data.&lt;/P&gt;&lt;P&gt;Can you confirm that condition I applied is correct.&lt;/P&gt;&lt;P&gt;is this code will work for a large data also.&lt;/P&gt;&lt;P&gt;please suggest if further refinement to this code should be done.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 12:21:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723428#M80246</guid>
      <dc:creator>jay_bhavsar</dc:creator>
      <dc:date>2021-03-04T12:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: locf CODE CONFIRMATION</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723438#M80247</link>
      <description>&lt;P&gt;Please do us (and yourself) a favor and post WORKING code.&lt;/P&gt;
&lt;P&gt;The communities provide a special window where you post code (simply by copy/pasting), open it with the "little running man" button right next to the one indicated:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 12:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723438#M80247</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-04T12:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: locf CODE CONFIRMATION</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723452#M80249</link>
      <description>&lt;P&gt;This simplified code does what I think you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input RANDOMNO Visit Value;
datalines;
1 0 1
1 1 5
1 2 .
1 3 7
1 4 .
1 5 1
2 0 3
2 1 .
2 2 .
2 3 4
2 4 5
2 5 .
3 0 .
3 1 .
3 2 6
3 3 .
3 4 8
3 5 0
;

proc sort data=have;
by RANDOMNO Visit;
run;

data want;
set have;
by randomno;
length DTYPE $15;
retain vlocf;
if first.RANDOMNO then vlocf = .;
vlocf = coalesce(value,vlocf);
if value = . then DTYPE = "LOCF";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Mar 2021 13:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723452#M80249</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-04T13:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: locf CODE CONFIRMATION</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723758#M80257</link>
      <description>Thank you KurtBremser,&lt;BR /&gt;this code is doing good, But one problem is it showing DTYPE = LOCF where locf is not done.&lt;BR /&gt;and i dnt want to locf baseline (visit 0) values but in this code its doing that.</description>
      <pubDate>Fri, 05 Mar 2021 04:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723758#M80257</guid>
      <dc:creator>jay_bhavsar</dc:creator>
      <dc:date>2021-03-05T04:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: locf CODE CONFIRMATION</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723789#M80258</link>
      <description>&lt;P&gt;Then add a second condition here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if value = . then DTYPE = "LOCF";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;and vlocf ne .&lt;/LI-SPOILER&gt;</description>
      <pubDate>Fri, 05 Mar 2021 07:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/locf-CODE-CONFIRMATION/m-p/723789#M80258</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-05T07:40:06Z</dc:date>
    </item>
  </channel>
</rss>

