
- by Handson
- March 27, 2025
Generating TLF (Tables, Listings, and Figures) in SAS for Clinical Trial Reporting
A TLF (Tables, Listings, and Figures) project in SAS programming is commonly used in clinical trials to analyze and report data. Below is a basic TLF project structure using SAS:
1. Steps to Generate a TLF Project:
-
Prepare Raw Data – Import and clean clinical trial data.
-
Create Derived Datasets – Generate ADaM datasets for analysis.
-
Generate Tables (T) – Summary tables for demographics and results.
-
Generate Listings (L) – Patient-level listings of raw or derived data.
-
Generate Figures (F) – Graphical representations of trial outcomes.
-
Format Output and Report – Export results in RTF, PDF, or Excel.
2. Sample SAS Code for a TLF Project
Step 1: Import Clinical Data (SDTM or Raw Data)
libname rawdata "C:ClinicalTrialRawData"; data clinical_data; set rawdata.trial_data; where treatment in ("DrugA", "Placebo"); run;
Step 2: Create an ADaM Dataset for Analysis
data adam.adsl; set clinical_data; age_group = ifc(age >= 65, "Elderly", "Adult"); if missing(weight) then weight = mean(weight); keep subject_id sex age age_group weight height treatment; run;
Step 3: Generate Summary Table for Demographics
proc freq data=adam.adsl; tables sex age_group treatment / out=demographics_summary; run; proc print data=demographics_summary; title "Demographic Summary Table"; run;
Step 4: Generate Listings of Adverse Events
proc sort data=rawdata.adverse_events out=sorted_ae; by subject_id; run; proc print data=sorted_ae noobs; title "Adverse Events Listing"; var subject_id event_type severity treatment; run;
Step 5: Generate Figures (Graphs)
TLF (Tables, Listings, and Figures) project using the WORK library in SAS. This project will:
-
Import mock clinical trial data.
-
Create an ADaM dataset.
-
Generate a summary table (T).
-
Generate a listing of adverse events (L).
-
Generate a figure (F) showing weight distribution across treatments.
Step 1: Import Mock Clinical Data
data work.clinical_data; input Subject_ID $ Sex $ Age Weight Height Treatment $; datalines; 101 M 34 78 175 DrugA 102 F 45 65 162 Placebo 103 M 29 85 180 DrugA 104 F 50 70 160 Placebo 105 M 40 90 176 DrugA 106 F 38 68 158 Placebo ; run; proc print data=work.clinical_data; title "Raw Clinical Data"; run;
Step 2: Create an ADaM Dataset
data work.adsl; set work.clinical_data; Age_Group = ifc(Age >= 40, "Older", "Younger"); keep Subject_ID Sex Age Age_Group Weight Height Treatment; run; proc print data=work.adsl; title "ADaM Subject-Level Dataset"; run;
Step 3: Generate a Summary Table (T)
proc freq data=work.adsl; tables Sex Age_Group Treatment / out=work.demographics_summary; run; proc print data=work.demographics_summary; title "Demographic Summary Table"; run;
Step 4: Generate Listings of Adverse Events (L)
data work.adverse_events; input Subject_ID $ Event_Type $ Severity $ Treatment $; datalines; 101 Headache Mild DrugA 102 Nausea Moderate Placebo 103 Dizziness Severe DrugA 104 Fatigue Mild Placebo 105 Rash Moderate DrugA 106 Vomiting Severe Placebo ; run; proc print data=work.adverse_events noobs; title "Adverse Events Listing"; run;
Step 5: Generate a Figure (F) - Weight Distribution
proc sgplot data=work.adsl; vbar Treatment / response=Weight stat=mean; title "Mean Weight by Treatment Group"; run;
Summary:
-
Tables (T): Generated a demographic summary table.
-
Listings (L): Created an adverse events listing.
-
Figures (F): Plotted a weight distribution graph by treatment group.