Published on :
ETL CREATION_INTERNE

Creation of Metadata for Laboratory Variables

This code is also available in: Deutsch Español Français
Awaiting validation
The script initializes a path via a macro variable, then assigns a SAS© library to it. It then uses a DATA step with 'datalines' to manually define metadata for various laboratory variables (study ID, domain, unique subject ID, etc.). For each variable, it determines the type (character or numeric), length, and label, and assembles this information into a formatted 'attr' string that could be used to dynamically generate variable attributes (for example, for ATTRIB statements).
Data Analysis

Type : CREATION_INTERNE


The data is created directly within the SAS script via the `datalines` clause. It defines the metadata for laboratory variables (name, type, length, label).

1 Code Block
Macro/Libname
Explanation :
This block defines a macro variable `path` with a directory path. Then, it assigns a SAS library named `meta` to this path. This library will be used to store the metadata dataset created subsequently.
Copied!
1%let path = H:\GraphicsGroup\dummy\sdtm-style\meta;
2LIBNAME meta "&path";
3 
2 Code Block
DATA STEP Data
Explanation :
This DATA step creates the `lb_meta` dataset in the `meta` library. It reads embedded raw data (datalines) for the `name`, `type`, `length`, and `label` columns. The script then calculates a new variable `attr` which formats this information into a SAS attribute string, including the variable name, its label, its type (if character), and its length. This allows for dynamic generation of variable attributes for later use in other SAS steps.
Copied!
1DATA meta.lb_meta;
2 INPUT name $ 1-8 type $ 10-13 LENGTH $ 16-18 label $ 22-61;
3 LENGTH attr $100;
4 attr = trim(name) || " label='" || trim(label) || "' length=";
5 IF type = "char" THEN
6 attr = trim(attr) || "$";
7 attr = trim(attr) || trim(LENGTH);
8*--------1---------2---------3---------4---------5---------6-;
9DATALINES;
10STUDYID char 25 Study Identifier
11DOMAIN char 2 Domain Abbreviation
12USUBJID char 25 Unique Subject Identifier
13LBSEQ num 8 Sequence Number
14LBGRPID char 25 Group ID
15LBREFID char 25 Specimen ID
16LBSPID char 25 Sponsor-Defined Identifier
17LBTESTCD char 8 Lab Test or Examination Short Name
18LBTEST char 50 Lab Test or Examination Name
19LBCAT char 50 Category for Lab Test
20LBSCAT char 50 Subcategory for Lab Test
21LBORRES char 25 RESULT or Finding in Original Units
22LBORRESU char 25 Original Units
23LBORNRLO char 25 Reference Range Lower Limit in Orig Unit
24LBORNRHI char 25 Reference Range Upper Limit in Orig Unit
25LBSTRESC char 25 Character RESULT/Finding in Std FORMAT
26LBSTRESN num 8 Numeric RESULT/Finding in Standard Units
27LBSTRESU char 25 Standard Units
28LBSTNRLO num 8 Reference Range Lower Limit-Std Units
29LBSTNRHI num 8 Reference Range Upper Limit-Std Units
30LBSTNRC char 25 Reference Range for Char Rslt-Std Units
31LBNRIND char 25 Reference Range Indicator
32LBSTAT char 25 Completion STATUS
33LBREASND char 200 Reason Test Not Done
34LBNAM char 200 Vendor Name
35LBLOINC char 50 LOINC Code
36LBSPEC char 50 Specimen Type
37LBSPCCND char 50 Specimen Condition
38LBMETHOD char 50 Method of Test or Examination
39LBBLFL char 1 Baseline Flag
40LBFAST char 1 Fasting STATUS
41LBDRVFL char 1 Derived Flag
42LBTOX char 25 Toxicity
43LBTOXGR char 25 Standard Toxicity Grade
44VISITNUM num 8 Visit Number
45VISIT char 100 Visit Name
46VISITDY num 8 Planned Study Day of Visit
47LBDTC char 19 Date/Time of Measurement
48LBENDTC char 19 END Date/Time of Specimen Collection
49LBDY num 8 Study Day of Specimen Collection
50LBTPT char 25 Planned Time Point Name
51LBTPTNUM num 8 Planned Time Point Number
52LBELTM char 19 Planned Elapsed Time from Time Point Ref
53LBTPTREF char 25 Time Point Reference
54LBRFTDTC char 19 Date/Time of Reference Time Point
55;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.