Discover More Tips and Techniques on This Blog

CMENRTPT vs CMENRF in SDTM

Understanding CMENRTPT vs CMENRF in SDTM

By Sarath

Introduction

When working with the Concomitant Medication (CM) domain in SDTM, it's crucial to understand how timing variables like CMENRTPT (End Relative to Reference Time Point) and CMENRF (End Relative to Reference Period) differ and when to use each.

What is CMENRTPT?

CMENRTPT indicates the relationship between the end of the medication and a specific time point, such as the start of treatment or a significant event (e.g., surgery).

  • Controlled Terminology: BEFORE, AFTER, ONGOING, CONCURRENT
  • Example: If a medication was stopped before surgery, CMENRTPT = "BEFORE".

What is CMENRF?

CMENRF describes whether the medication ended before, during, or after a specific study period, such as Screening, Treatment, or Follow-up.

  • Controlled Terminology: BEFORE, DURING, AFTER
  • Example: If a medication ended during the treatment phase, CMENRF = "DURING".

Key Differences

Aspect CMENRTPT CMENRF
Focus Relationship to a specific time point Relationship to a study period
Granularity More precise Broader
Typical Use Case Linking to an event like surgery Contextualizing within a study phase

Example Scenario

Scenario: A medication was stopped two days after surgery, which occurred during the screening phase.

  • CMENRTPT: AFTER (relative to surgery)
  • CMENRF: BEFORE (relative to the start of the treatment phase)

Conclusion

By understanding the differences between CMENRTPT and CMENRF, clinical programmers can ensure accurate and standardized representation of concomitant medication timing in SDTM datasets. Always refer to the study protocol and CDISC standards to select the appropriate variable for your data.

© 2024 Sarath. All rights reserved.

Resolving the SAS EG Transcoding Error

Addressing the "Character Data Lost During Transcoding" Issue in SAS EG

Author: Sarath

Date: November 19, 2024

Introduction

While working in SAS Enterprise Guide (SAS EG), you may encounter the error: "Some character data was lost during transcoding in the dataset." This issue typically arises when character data contains unsupported characters or is truncated due to insufficient column lengths. In this blog post, we'll explore the root causes and provide step-by-step solutions.

Common Causes

  • Unsupported Characters: The data contains special or non-ASCII characters not representable in the session encoding.
  • Truncation: Character variables are too short to store the full data, leading to loss of information.
  • Encoding Mismatch: The dataset's encoding differs from the SAS session's encoding.

Step-by-Step Solutions

1. Check Encoding

Identify the encoding of your SAS session and dataset:

proc options option=encoding; run;
proc contents data=tempdata.cm; run;

2. Identify Problematic Characters

Review a sample of the dataset to locate non-representable or truncated characters:

proc print data=tempdata.cm (obs=50); run;

3. Use a Compatible Encoding

Adjust the encoding for your session or dataset. For example, specify UTF-8 if working with multilingual data:

libname tempdata 'path-to-data' inencoding='utf-8';

4. Increase Column Lengths

Expand the length of character variables to avoid truncation:

data tempdata.cm;
    set tempdata.cm;
    length newvar $200; /* Adjust length */
    newvar = oldvar;
run;

5. Transcode the Dataset

Convert the dataset into a compatible encoding:

libname tempdata_in 'path-to-input-data' inencoding='utf-8';
libname tempdata_out 'path-to-output-data' encoding='utf-8';

data tempdata_out.cm;
    set tempdata_in.cm;
run;

6. Modify Encoding with PROC DATASETS

Repair the dataset’s encoding directly:

proc datasets lib=tempdata;
    modify cm / correctencoding='utf-8';
quit;

7. Clean the Data

Handle non-printable or invalid characters using functions like KCOMPRESS or KSTRIP.

Best Practices

  • Ensure consistent encoding between your data sources and SAS session.
  • Use UTF-8 encoding for handling multilingual data.
  • Allocate sufficient column lengths for character variables during data transformation.

Conclusion

Resolving transcoding errors in SAS EG requires identifying the root cause and applying the appropriate solution. By following the steps outlined above, you can ensure your character data is correctly processed without loss or truncation.

Have questions or insights? Share them in the comments below!

Advanced SAS programming Techniques for SDTM implementation

Advanced SAS Programming Techniques for SDTM Implementation

Date: November 3, 2024

In the realm of clinical trials data management, SDTM (Study Data Tabulation Model) implementation requires sophisticated programming techniques to ensure data accuracy and compliance. This article explores advanced SAS programming methods that can streamline SDTM dataset creation and validation.

1. Efficient Variable Derivation Using Hash Objects

Hash objects in SAS provide a powerful way to perform quick lookups and merges, especially useful when dealing with large SDTM datasets.

data work.ae;
if _n_ = 1 then do;
declare hash h_dm(dataset: "sdtm.dm");
h_dm.definekey("usubjid");
h_dm.definedata("age", "sex", "race");
h_dm.definedone();
end;
set raw.ae;
rc = h_dm.find();
/* Continue processing */
run;

Pro Tip: Hash objects remain in memory throughout the DATA step, making them more efficient than traditional merge operations for large datasets.

2. Standardizing Controlled Terminology with Format Catalogs

Creating and maintaining CDISC-compliant terminology is crucial for SDTM implementation.

proc format library=library.sdtm_formats;
value $severity
'MILD' = 'MILD'
'MOD' = 'MODERATE'
'MODERATE' = 'MODERATE'
'SEV' = 'SEVERE'
'SEVERE' = 'SEVERE'
other = 'UNKNOWN';
run;

data sdtm.ae;
set work.ae;
aesev = put(raw_severity, $severity.);
run;

3. Macro Systems for Dynamic SDTM Generation

Developing reusable macro systems can significantly improve efficiency and reduce errors in SDTM implementation.

%macro create_supp(domain=, vars=);
proc sql noprint;
select distinct usubjid, &vars
into :subjids separated by ',',
:values separated by ','
from sdtm.&domain;
quit;

data sdtm.supp&domain;
set sdtm.&domain(keep=usubjid &vars);
length qnam $8 qlabel $40 qval $200;
/* Generate supplemental qualifiers */
run;
%mend create_supp;

4. Advanced Error Checking and Validation

Implementing robust error-checking mechanisms ensures data quality and compliance with SDTM standards.

%macro validate_domain(domain=);
proc sql noprint;
/* Check for duplicate records */
create table work.duplicates as
select *, count(*) as count
from sdtm.&domain
group by usubjid, &domain.dtc
having count > 1;
/* Verify required variables */
select name into :reqvars separated by ' '
from sashelp.vcolumn
where libname='SDTM' and memname=upcase("&domain")
and name in ('USUBJID', 'DOMAIN', "&domain.SEQ");
quit;
%mend validate_domain;

5. Handling Custom Domains and Extensions

Sometimes, standard SDTM domains need to be extended to accommodate study-specific requirements.

proc sql;
create table sdtm.custom_domain as
select a.usubjid,
a.visit,
b.startdt,
calculated enddt format=datetime20.
from derived.custom_data as a
left join sdtm.sv as b
on a.usubjid = b.usubjid
and a.visit = b.visit;
quit;

6. Optimizing Performance for Large Studies

When dealing with large studies, performance optimization becomes crucial:

  1. Use WHERE clauses instead of IF statements when possible
  2. Implement parallel processing for independent domains
  3. Optimize sort operations using PROC SORT NODUPKEY
options mprint mlogic symbolgen;
%let parallel_domains = ae cm eg lb mh vs;

%macro process_domains;
%do i = 1 %to %sysfunc(countw(¶llel_domains));
%let domain = %scan(¶llel_domains, &i);
%submit;
%create_domain(domain=&domain)
%endsubmit;
%end;
%mend process_domains;

Best Practice: Always document your code thoroughly and include version control information for traceability.

Conclusion

Mastering these advanced SAS programming techniques can significantly improve the efficiency and quality of SDTM implementation. Remember to always validate your outputs against SDTM Implementation Guide requirements and maintain clear documentation of your programming decisions.

Disclosure:

In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers. My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.