myCSG © |Area: SDTM| Concept: LB : Laboratory Test Results | Lesson: LCSG001 : LB dataset Programming for study CSG001 |

In this lesson, we will see:

  • Basic programming of SDTM LB dataset.
    • Data from chemistry, hematlogy and urinalysis is present
    • Conversion of results from original units to standard units using metadata
    • Creation of normal range indicator
    • Creation of baseline flag etc.
variable_namevariable_labelderivation
General Laboratory tests are collected in three different datasets, lab_hema, lab_chem and lab_urin. So, these three datasets become the base input datasets for creating SDTM.LB dataset. The information related to the tests performed are collected as rows in the input datasets which is same as the expected structure for SDTM LB domain - one record per subject per test per timepoint. The three input datasets share the same structure.
A standard lab metadata dataset named lb_meta is available and this contains the standard unit, conversion factor for standard unit, LBTEST value for each analyte collected and also the number of decimal places expected for result of each test.
STUDYID Study Identifier Populate using STUDY variable
DOMAIN Domain Abbreviation Populate as "LB"
USUBJID Unique Subject Identifier Concatenate STUDY and PT variable values using hyphen as separator
LBSEQ Sequence Number Sort the final dataset by USUBJID, LBCAT, LBTESTCD, LBDTC and set to 1 on the first record of the subject and increment by 1 on subsequent records.
LBTESTCD Lab Test or Examination Short Name. Populate with the value from TEST variable.
LBTEST Lab Test or Examination Name Populate using LBTEST value lab_meta by merging at TEST and UNIT level (lab.TEST=meta.LBTESTCD and lab.COLL_UNIT=meta.LBORRESU)
LBCAT Category for Lab Test Populate as "HEMATOLOGY" for records coming from lab_hema.
Populate as "CHEMISTRY" for records coming from lab_chem.
Populate as "URINALYSIS" for records coming from lab_urin.
LBORRES Result or Finding in Original Units Populate with the value from COLL_RSLT variable.
LBORRESU Original Units Populate with the value from COLL_UNIT variable.
LBORNRLO Reference Range Lower Limit in Orig Unit Populate with the value from LOWER variable.
LBORNRHI Reference Range Upper Limit in Orig Unit Populate with the value from HIGHER variable.
LBSTRESC Character Result/Finding in Std Format 1) Fetch CONVERSION value and DECIMAL value from lab_meta by merging at TEST and UNIT level (lab.TEST=meta.LBTESTCD and lab.COLL_UNIT=meta.LBORRESU).
2) Where applicable, convert the numeric component of COLL_RSLT to standard unit by multiplying with conversion factor.
3) Round the resulting value to number of decimals specified in the metadata.
4) If there exists special characters like '<', '<=', '>', '>=' , concatenate these symbols back to the standard result.
Same methodology is applicable for other similar variables, entire derivation logic is not repeated in other places.
LBSTRESN Numeric Result/Finding in Standard Units Refer LBSTRESC for derivation approach.
Note: LBSTRESN will be left null in cases where special characters exist in LBORRES.
LBSTRESU Standard Units Populate with LBSTRESU from metadata.
LBSTNRLO Reference Range Lower Limit-Std Units Refer LBSTRESC for derivation approach.
LBSTNRHI Reference Range Upper Limit-Std Units Refer LBSTRESC for derivation approach.
LBNRIND Reference Range Indicator Derived using LBSTNRLO, LBSTNRHI and LBSTRESN.
1) For the lab tests where lower limit and upper limit are available, populae as "HIGH" if the result is greater than upper limit, populate as "LOW" if the result is lower than lower limit, else populate as "NORMAL" when result is not null.
2) For the lab tests where only lower limit is available, populate as "LOW" if result is less than the lower limit, else populate as "NORMAL" if result is greater than or equals to lower limit.
LBSPEC Specimen Type Populate with the value from SPECIMEN.
LBBLFL Baseline Flag Set to "Y" on the latest record with non-missing result on or prior to SDTM.DM.RFSTDTC per LBCAT and LBTESTCD of each subject.
VISITNUM Visit Number Set to 1 when VISIT="SCREENING" Else when VISIT contains "WEEK" then add 100 to the week number (that is, WEEK 1 will have a VISITNUM of 101) Else when VISIT contains "FOLLOW-UP" then add 200 to the numeric portion of the VISIT
VISIT Visit Name Set to "SCREENING" when FOLDER="SCR" Else when FOLDER contains "Week" then convert FOLDER to uppercase Else when FOLDER contains "FU" then replace "FU" with "FOLLOW-UP"
LBDTC Date/Time of Specimen Collection Convert LBDT_RAW into ISO 8601 format.
LBDY Study Day of Specimen Collection numeric(datepart(LBDTC))-numeric(datepart(DM.RSTDTC))+(numeric(datepart(LBDTC))>=numeric(datepart(DM.RFSTDTC)))
Complete SAS code to generate the output is available for registered users!

Already registered! Login
Not registered, you can signup here! Signup

Dont want to register?
You can directly purchase this lesson (code+input data) here


You can purchase this lesson (code+input data) here

If you are looking to purchase subscription for full access to data and programs for all lessons (TASKS+SDTM+ADaM+TFLs), you can send us a message on +91-7330--77--66--49-- on Whatsapp.
R data is available only for R subscribers.
You can contact us on +91-7330--77--66---49 for purchasing subscription to R programs and data
R codes are available only for R subscribers.
You can contact us on +91-7330--77--66---49 for purchasing subscription to R programs and data