<?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: Lab Shift table in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Lab-Shift-table/m-p/8594#M830</link>
    <description>Thank you very much for the explanation.  I appreciate it.</description>
    <pubDate>Thu, 03 Apr 2008 01:07:27 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-04-03T01:07:27Z</dc:date>
    <item>
      <title>Lab Shift table</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Lab-Shift-table/m-p/8592#M828</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I have a piece of SAS program I find difficult to understand.  I am in the process of creating a Laboratory Shift Table.&lt;BR /&gt;
&lt;BR /&gt;
I have two datasets:  dataset treat (variables are subjid and trtcode) and a lab dataset (variables are subjid, lbcat, lbtest, lbsu, lbresu, lbnrlw, lbnrhi, lbrefind, wk).&lt;BR /&gt;
&lt;BR /&gt;
subjid-Subject ID&lt;BR /&gt;
trtcode- treatment code (0 for placebo and 1 for Active)&lt;BR /&gt;
lbcat- Lab test category (eg. Hematology)&lt;BR /&gt;
lbtest-Lab test (eg. Hematocrit, hemoglobin, etc)&lt;BR /&gt;
lbsu- Standard units&lt;BR /&gt;
lbresu-lab result in std units&lt;BR /&gt;
lbnrlo-normal range lower limit&lt;BR /&gt;
lbnrhi-normal range higher limit&lt;BR /&gt;
lbrefind-Range indicator (eg. L for low, N for normal, H for high)&lt;BR /&gt;
wk=week (values are 0,1, 2, 3, 4)&lt;BR /&gt;
&lt;BR /&gt;
I could merge both both datsets after sorting and got the desired output.  I do not understand the need of the following code:&lt;BR /&gt;
&lt;BR /&gt;
dataset lb is the result of merge&lt;BR /&gt;
&lt;BR /&gt;
data lb;&lt;BR /&gt;
   set lb;&lt;BR /&gt;
      by subjid lbcat lbtest lbresu wk;&lt;BR /&gt;
&lt;BR /&gt;
      retain baseflag " ";&lt;BR /&gt;
&lt;BR /&gt;
       if first.lbtest then&lt;BR /&gt;
         baseflag = " ";&lt;BR /&gt;
&lt;BR /&gt;
        if week = 0 then&lt;BR /&gt;
         baseflag = lbrefind;&lt;BR /&gt;
run;&lt;BR /&gt;
  &lt;BR /&gt;
Just after merge, the dataset has the following structure&lt;BR /&gt;
&lt;BR /&gt;
subjid   lbcat   lbtest   lbsu   lbresu   lbnrlo   lbnrhi   lbrefind   wk   trtcode&lt;BR /&gt;
&lt;BR /&gt;
100     Hemat hemog g/dL   11.5     11.7    15.9      L            0       1&lt;BR /&gt;
100     Hemat hemog g/dL   13.2      11.7    15.9     N            1       1&lt;BR /&gt;
100     Hemat hemog g/dL    13.7     11.7    15.9     N            2       1&lt;BR /&gt;
100     Hemat hemog g/dL    13.9     11.7    15.9     N            3       1&lt;BR /&gt;
100     Hemat hemog g/dL    14.0     11.7    15.9     N            4       1 &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
But after subitting the above code which introduces the baseflag variable, the dataset has the following structure :&lt;BR /&gt;
&lt;BR /&gt;
subjid   lbcat   lbtest   lbsu   lbresu   lbnrlo   lbnrhi   lbrefind   wk   trtcode  baseflag&lt;BR /&gt;
&lt;BR /&gt;
100     Hemat hemog g/dL   11.5     11.7    15.9      L            0       1      L&lt;BR /&gt;
100     Hemat hemog g/dL   13.2      11.7    15.9     N            1       1      L&lt;BR /&gt;
100     Hemat hemog g/dL    13.7     11.7    15.9     N            2       1      L&lt;BR /&gt;
100     Hemat hemog g/dL    13.9     11.7    15.9     N            3       1      L&lt;BR /&gt;
100     Hemat hemog g/dL    14.0     11.7    15.9     N            4       1      L&lt;BR /&gt;
&lt;BR /&gt;
I undertstand that this happened because of the retain statement.  My question is that why do we need to introduce this flag?  I will be soon working on lab shift table, and I am just trying to get familiar.&lt;BR /&gt;
&lt;BR /&gt;
Any input is highly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Cathy</description>
      <pubDate>Wed, 02 Apr 2008 17:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Lab-Shift-table/m-p/8592#M828</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-02T17:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: Lab Shift table</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Lab-Shift-table/m-p/8593#M829</link>
      <description>It is a baselining variable.&lt;BR /&gt;
&lt;BR /&gt;
What it is doing, or will do if you had more data, is storing the Range Indicator of Week 0 for each set and then augmenting the Week 0 Range Indicator to subsequent weeks for the same set. Then when the week is reset to 0, assuming a new set, it re-establishes the Week 0 Baseline and augments that to the next set.&lt;BR /&gt;
&lt;BR /&gt;
Most likely, this is done for later comparision analysis, if the results change from the Week 0 baseline, {Week 1 in your example] you can easily query when that happens, since (lbrefind NEQ baseflag)&lt;BR /&gt;
&lt;BR /&gt;
Set being defined as a {subjid, lbcat, lbtest, lbresu} tuple.&lt;BR /&gt;
&lt;BR /&gt;
Ike</description>
      <pubDate>Wed, 02 Apr 2008 20:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Lab-Shift-table/m-p/8593#M829</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-02T20:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Lab Shift table</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Lab-Shift-table/m-p/8594#M830</link>
      <description>Thank you very much for the explanation.  I appreciate it.</description>
      <pubDate>Thu, 03 Apr 2008 01:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Lab-Shift-table/m-p/8594#M830</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-04-03T01:07:27Z</dc:date>
    </item>
  </channel>
</rss>

