<?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: Last observation carrying forward for a subject. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410617#M100321</link>
    <description>&lt;P&gt;Look up RETAIN&lt;/P&gt;</description>
    <pubDate>Sun, 05 Nov 2017 00:19:13 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-11-05T00:19:13Z</dc:date>
    <item>
      <title>Last observation carrying forward for a subject.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410614#M100320</link>
      <description>&lt;P&gt;&lt;BR /&gt;data gd;&lt;BR /&gt;input id$ visit sbp dbp;&lt;BR /&gt;cards;&lt;BR /&gt;001 10 120 90&lt;BR /&gt;001 10 110 .&lt;BR /&gt;001 10 130 .&lt;BR /&gt;001 20 110 90&lt;BR /&gt;001 30 110 98&lt;BR /&gt;002 10 120 .&lt;BR /&gt;002 10 110 80&lt;BR /&gt;002 10 130 98&lt;BR /&gt;002 20 110 90&lt;BR /&gt;002 30 110 98&lt;BR /&gt;003 10 120 90&lt;BR /&gt;003 10 110 80&lt;BR /&gt;003 10 130 98&lt;BR /&gt;003 10 110 90&lt;BR /&gt;003 20 120 .&lt;BR /&gt;003 30 110 98&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a subject if sys, dbp is missing after first record we need to return first value to it missing value to it next records. If first record is also missing for a subject we need to set to missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=gd;by id visit;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data gd4;&lt;BR /&gt;set gd;&lt;BR /&gt;by id visit;&lt;BR /&gt;if first.id;&lt;BR /&gt;b=dbp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data gd6;&lt;BR /&gt;merge gd gd4;&lt;BR /&gt;by id;&lt;BR /&gt;/*if missing(dbp) then dbp=b;*/&lt;BR /&gt;/*else b=dbp;*/&lt;BR /&gt;/*b=dbp;*/&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 00:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410614#M100320</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2017-11-05T00:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Last observation carrying forward for a subject.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410617#M100321</link>
      <description>&lt;P&gt;Look up RETAIN&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 00:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410617#M100321</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-05T00:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Last observation carrying forward for a subject.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410619#M100322</link>
      <description>&lt;P&gt;I find part of your problem description a bit ambiguous.&amp;nbsp;&amp;nbsp; You said (&lt;EM&gt;&lt;STRONG&gt;bold-italics&lt;/STRONG&gt;&lt;/EM&gt; are mine)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a subject if sys, dbp is missing after first record we need to return first value to it missing value to it next records. I&lt;EM&gt;&lt;STRONG&gt;f first record is also missing for a subject we need to set to missing&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by "first record is also missing"?&amp;nbsp;&amp;nbsp; That it is missing in addition to a later missing obs?&amp;nbsp;&amp;nbsp; Do you mean if first obs is missing, then all obs should be set to missing?&amp;nbsp; Please give an example of desired output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 00:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410619#M100322</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-11-05T00:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Last observation carrying forward for a subject.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410620#M100323</link>
      <description>&lt;P&gt;Required Output:&lt;BR /&gt;&lt;BR /&gt;data gd;&lt;BR /&gt;input id$ visit sbp dbp;&lt;BR /&gt;cards;&lt;BR /&gt;001 10 120 90&lt;BR /&gt;001 10 110 90&lt;BR /&gt;001 10 130 90&lt;BR /&gt;001 20 110 90&lt;BR /&gt;001 30 110 98&lt;BR /&gt;002 10 120 .&lt;BR /&gt;002 10 110 80&lt;BR /&gt;002 10 130 98&lt;BR /&gt;002 20 110 90&lt;BR /&gt;002 30 110 98&lt;BR /&gt;003 10 120 90&lt;BR /&gt;003 10 110 80&lt;BR /&gt;003 10 130 98&lt;BR /&gt;003 10 110 90&lt;BR /&gt;003 20 120 90&lt;BR /&gt;003 30 110 98&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 00:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410620#M100323</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2017-11-05T00:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Last observation carrying forward for a subject.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410621#M100324</link>
      <description>&lt;P&gt;Retain Y;&lt;/P&gt;
&lt;P&gt;if not missing(dbp) or first.ID then Y=dbp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 00:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410621#M100324</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-05T00:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Last observation carrying forward for a subject.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410622#M100325</link>
      <description>&lt;P&gt;Thanks Reeza....&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 01:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-observation-carrying-forward-for-a-subject/m-p/410622#M100325</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2017-11-05T01:02:22Z</dc:date>
    </item>
  </channel>
</rss>

