The following example
demonstrates generating Oracle SQL code for the CDISC SDTM AE data
set:
%cstutilsqlgeneratetable(_cstDSName=AE,_cstDSLibraryIn=SDTM32,_cstDSLibraryOut=test,
_cstSQLFile=c:\test\create_oracleSQL.sas,_cstSQLType=ORACLE);
The following is an
excerpt of the generated code in the create_oracleSQL.sas file:
create table AE
(STUDYID varchar2(40), DOMAIN__SQL1 varchar2(8), USUBJID varchar2(40), AESEQ numeric, AEGRPID...);
insert into AE (STUDYID, DOMAIN__SQL1, USUBJID, AESEQ, AEGRPID, AEREFID, AESPID, AETERM, AEMODIFY...)
values ('SASCSTDEMODATA' , 'AE' , 'S001P002' , 1, '' , '' , '' , 'ABDOMINAL PAIN' , '' , '' , NULL,...)
insert into AE (STUDYID, DOMAIN__SQL1, USUBJID, AESEQ, AEGRPID, AEREFID, AESPID, AETERM, AEMODIFY,...)
values ('SASCSTDEMODATA' , 'AE' , 'S001P003' , 2, '' , '' , '' , 'ABDOMINAL CRAMP' , '' ,...)
insert into AE (STUDYID, DOMAIN__SQL1, USUBJID, AESEQ, AEGRPID, AEREFID, AESPID, AETERM, AEMODIFY,...)
values ('SASCSTDEMODATA' , 'AE' , 'S001P003' , 3, '' , '' , '' , 'RASH' , '' , 'Rash' , 10037844,...)
.
.
.
insert into AE (STUDYID, DOMAIN__SQL1, USUBJID, AESEQ, AEGRPID, AEREFID, AESPID, AETERM, AEMODIFY,...)
values ('SASCSTDEMODATA' , 'AE' , 'S003P019' , 106, '' , '' , '' , 'HEARTBURN-LIKE DYSPEPSIA' , '' ,...);
;
Note: The line (STUDYID
varchar2(40), DOMAIN__SQL1 varchar2(8), USUBJID varchar2(40), AESEQ
numeric, AEGRPID...);
came from the call to %CSTUTILSQLCOLUMNDEFINITION.
Notice the DOMAIN column
from the AE data set has been renamed in the generated Oracle SQL
code as DOMAIN__SQL1. The word “domain” is a reserved
word in Oracle SQL. Therefore, the macro appends __SQL1. You must
decide where to change this column name: In the data set before submitting
the macro or in the generated Oracle SQL code (to rename the column
in the generated table).
After submitting the
macro, the SAS log file contains the following warning message:
[CSTLOGMESSAGE.CSTUTILSQLCOLUMNDEFINITION] WARNING: Column [DOMAIN ] is an ORACLE SQL
RESERVED WORD - This column may need to be changed in the contributing SAS data set.
[CSTLOGMESSAGE.CSTUTILSQLCOLUMNDEFINITION] WARNING: Column [DOMAIN ] is being renamed to
DOMAIN__SQL1 .