<?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: BASE sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474022#M121732</link>
    <description>&lt;P&gt;Since you need to inspect both the baseline and predose values, two loops can do the trick:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.subjid);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by subjid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if visit in ('screening', 'predose') and lbstresn &amp;gt; . then base = lbstresn;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.subjid);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by subjid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jun 2018 11:02:27 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-06-28T11:02:27Z</dc:date>
    <item>
      <title>Create column from last non-missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474014#M121728</link>
      <description />
      <pubDate>Sat, 30 Jun 2018 01:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474014#M121728</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-06-30T01:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: BASE sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474015#M121729</link>
      <description>&lt;P&gt;please make a correction&amp;nbsp; --&amp;gt;fourth record from last should contain 44 as base value instead of 120&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 09:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474015#M121729</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-06-28T09:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: BASE sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474017#M121731</link>
      <description>&lt;P&gt;So its just retaining the row with the word screening?&amp;nbsp; Then its simple:&lt;/P&gt;
&lt;PRE&gt;data want;
  set lab;
  retain base;
  if visit="screening" then base=lbstresn;
run;&lt;/PRE&gt;
&lt;P&gt;However I suspect its more complicated than that.&amp;nbsp; I assume your creating an ADaM dataset, so want a baseline flag.&amp;nbsp; To do this first create a dataset with all the baseline values, then merge this back to your original data.&amp;nbsp; E.g.&lt;/P&gt;
&lt;PRE&gt;data base (keep=subjid lbtest base_val (rename=(lbstresn=base_val));
  set lab;
  where visit="screening";
run;

data want;
  merge lb base;
  by subjid lbtest;
run;&lt;/PRE&gt;
&lt;P&gt;You can then alter that to keep other variables, do more compicated baseline calculations, LOCF etc.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 09:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474017#M121731</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-28T09:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: BASE sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474022#M121732</link>
      <description>&lt;P&gt;Since you need to inspect both the baseline and predose values, two loops can do the trick:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do until (last.subjid);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by subjid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if visit in ('screening', 'predose') and lbstresn &amp;gt; . then base = lbstresn;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do until (last.subjid);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by subjid;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 11:02:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474022#M121732</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-28T11:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: BASE sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474174#M121788</link>
      <description>&lt;P&gt;hey thank you so much it worked.But still i didnt understood the trick of two loops .please explain.Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 17:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474174#M121788</guid>
      <dc:creator>Bhargav_Movva</dc:creator>
      <dc:date>2018-06-28T17:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: BASE sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474183#M121792</link>
      <description>&lt;P&gt;The top loop reads through all the observations for a subject.&amp;nbsp; Whenever it finds a nonmissing value (for selected visit types) it updates BASE.&amp;nbsp; So BASE is established at that point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the bottom DO loop reads exactly the same observations.&amp;nbsp; (When a DATA step contains multiple SET statements, each one operates independently of the other.)&amp;nbsp; It outputs those observations, along with the previously calculated value for BASE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to find more examples like this, you can search for DOW loops.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jun 2018 17:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-column-from-last-non-missing-value/m-p/474183#M121792</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-28T17:34:11Z</dc:date>
    </item>
  </channel>
</rss>

