Lab Shift table

Reply
N/A
Posts: 0

Lab Shift table

Hi all,

I have a piece of SAS program I find difficult to understand. I am in the process of creating a Laboratory Shift Table.

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).

subjid-Subject ID
trtcode- treatment code (0 for placebo and 1 for Active)
lbcat- Lab test category (eg. Hematology)
lbtest-Lab test (eg. Hematocrit, hemoglobin, etc)
lbsu- Standard units
lbresu-lab result in std units
lbnrlo-normal range lower limit
lbnrhi-normal range higher limit
lbrefind-Range indicator (eg. L for low, N for normal, H for high)
wk=week (values are 0,1, 2, 3, 4)

I could merge both both datsets after sorting and got the desired output. I do not understand the need of the following code:

dataset lb is the result of merge

data lb;
set lb;
by subjid lbcat lbtest lbresu wk;

retain baseflag " ";

if first.lbtest then
baseflag = " ";

if week = 0 then
baseflag = lbrefind;
run;

Just after merge, the dataset has the following structure

subjid lbcat lbtest lbsu lbresu lbnrlo lbnrhi lbrefind wk trtcode

100 Hemat hemog g/dL 11.5 11.7 15.9 L 0 1
100 Hemat hemog g/dL 13.2 11.7 15.9 N 1 1
100 Hemat hemog g/dL 13.7 11.7 15.9 N 2 1
100 Hemat hemog g/dL 13.9 11.7 15.9 N 3 1
100 Hemat hemog g/dL 14.0 11.7 15.9 N 4 1


But after subitting the above code which introduces the baseflag variable, the dataset has the following structure :

subjid lbcat lbtest lbsu lbresu lbnrlo lbnrhi lbrefind wk trtcode baseflag

100 Hemat hemog g/dL 11.5 11.7 15.9 L 0 1 L
100 Hemat hemog g/dL 13.2 11.7 15.9 N 1 1 L
100 Hemat hemog g/dL 13.7 11.7 15.9 N 2 1 L
100 Hemat hemog g/dL 13.9 11.7 15.9 N 3 1 L
100 Hemat hemog g/dL 14.0 11.7 15.9 N 4 1 L

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.

Any input is highly appreciated.

Thanks,


Cathy
N/A
Posts: 0

Re: Lab Shift table

It is a baselining variable.

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.

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)

Set being defined as a {subjid, lbcat, lbtest, lbresu} tuple.

Ike
N/A
Posts: 0

Re: Lab Shift table

Thank you very much for the explanation. I appreciate it.
Post a Question
Discussion Stats
  • 2 replies
  • 2823 views
  • 0 likes
  • 1 in conversation