Introduction
Castor Electronic Data Capture (EDC) exports study data using CDISC-compliant SAS Transport (.xpt) files. These files may contain variable names that include spaces, mixed case, or other characters that SAS does not accept under its default naming rules.
One common example from Castor exports is: 'Participant Id'n
This is a valid SAS name literal and reflects Castor’s internal structure, where Participant ID acts as a key variable. However, SAS may generate errors if its session settings do not allow such variable names.
Why SAS May Trigger an Error
When you open the export in SAS, your session defaults to VALIDVARNAME=V7. Under that rule, SAS only allows:
- letters, numbers, and underscores,
- ≤ 32 characters,
- no spaces or special characters.
So when SAS encounters something like 'Participant Id'n, it complains that it’s “not a valid SAS name”.
This is due to SAS naming rules and not an issue with Castor’s export structure.
Required SAS Settings Before Importing Castor XPT Files
To avoid this issue, before running PROC CIMPORT, configure:
options validvarname=any; /* allow spaces & special characters */
options validmemname=extend; /* allow extended dataset names */
Then re-run your PROC CIMPORT step
This tells SAS: “Allow quoted variable names exactly as they appear in the transport file.”
Referencing Variables Using SAS Name Literals
If you refer to a variable dataset or library name as a ‘name literal’:
Name literals (the 'variable name'n format) allow SAS to correctly interpret variable names that include spaces.
Normally, if you try to reference the variable like this:
data test;
set mydata;
x = Participant Id; /* invalid syntax */
run;
SAS will fail — it expects Participant and Id to be two different tokens.
But with a name literal, it works:
data test;
set mydata;
x = 'Participant Id'n; /* valid */
run;Examples
| Variable name | How to reference it | Works under with settings |
| participant_id | participant_id | VALIDVARNAME=V7 or ANY |
| Participant Id | 'Participant Id'n | Only VALIDVARNAME=ANY |
| 123Age | '123Age'n | Only VALIDVARNAME=ANY |
| AE/SAE Log | 'AE/SAE Log'n | Only VALIDVARNAME=ANY |
Optional: Renaming Variables to Remove Spaces
If your workflow requires SAS-compliant names without spaces, you can rename variables after import:
/* Example: rename just the problematic ones */
proc datasets lib=work nolist;
modify AE_SAE_LOG_20251104;
rename 'Participant Id'n = participant_id;
quit;
Summary
• Castor exports follow CDISC/SAS Transport standards.
• Errors occur due to SAS session settings, not the export files.
• Set validvarname=any and validmemname=extend before importing.
• Rename variables post-import if required.