Now, let's go back to the four major folders that we have and look at the Programmes folder:
The Programs folder contains the program we have for this project.
There are five sub-folders:
Now, click into the "1. Setup" folder.
There is a SAS program named "Setup":
Now you can open the file directly from SAS Studio.
Go to the Server Files and Folders menu at the top left corner.
You will be able to navigate down to the setup file:
Note: if you can't open the file directly from SAS Studio, you can copy the code below and paste it on SAS Studio.
The Setup.sas program contains the code to import the necessary data files:
options mprint mlogic;
/*Step 1: Change this to where the unzipped folder located in ur PC*/
%let Root = /folders/myfolders/Clinical Project - Part 1;
/*Step 2: Creating libraries*/
libname CDM "&root./data/data_sas/CDM";
libname SDTM "&root./data/data_sas/SDTM";
libname ADAM "&root./data/data_sas/ADAM";
/*Step 3: Creating sas data sets*/
/*CDM datasets*/
%macro CDM (Domain= ) ;
PROC IMPORT DATAFILE= "&root./data/data_excel/CDM/&domain..xlsx"
DBMS=XLSX OUT= CDM.&domain ;
GETNAMES=YES;
RUN;
%mend CDM ;
%CDM (Domain = DEATH ) ;
%CDM (Domain = DM ) ;
%CDM (Domain = DS ) ;
%CDM (Domain = EX ) ;
%CDM (Domain = IE ) ;
%CDM (Domain = SPCPKB1 ) ;
/*SDTM datasets*/
%macro SDTM (Domain= ) ;
PROC IMPORT DATAFILE= "&root./data/data_excel/SDTM/&domain..xlsx"
DBMS=XLSX OUT= SDTM.&domain ;
GETNAMES=YES;
RUN;
%mend SDTM ;
%SDTM (Domain = TA ) ;
Don't worry, we will explain the program line-by-line.
If you are using SAS University Edition, and you have saved the folders in the right location, you do NOT need to modify any part of the code.
If you are using any other version of SAS, you just need to modify one line of code, which we will show you very soon.
Now, run the entire program in SAS without modifying the code.
The program will create two new libraries named CDM and SDTM:
These are the data files we saw earlier in Excel format.
They have all been imported into SAS!
Program Explanation
The program involves mostly macros, but it is not as complex as it seems.
Let's look at each line, one-by-one.
Initial Option Statement
The initial OPTIONS statement specifies the MPRINT and MLOGIC options.
options mprint mlogic;
These options allow more information to be written to the SAS log when processing macros.
It is there for debugging purposes.
Creating the ROOT macro variable
The ROOT macro variable is created using the %LET statement.
/*Step 1: Change this to where the unzipped folder located in ur PC*/
%let Root = /folders/myfolders/Clinical Project - Part 1;
The macro variable identifies the location of the root directory.
This macro variable is extremely important.
Once the root directory is identified, SAS will be able to import any data files in any of the sub-folders.
Note: if you are not using SAS Studio, you can change the root directory to the proper folder.
Creating Libraries
Since we have multiple folders for the CDM, SDTM and ADAM data sets, we are going to create multiple libraries:
/*Step 2: Creating libraries*/
libname CDM "&root./data/data_sas/CDM";
libname SDTM "&root./data/data_sas/SDTM";
libname ADAM "&root./data/data_sas/ADAM";
The libraries are created using the LIBNAME statement.
It connects to the Data_sas folder that we saw earlier.
Importing CDM Data Files
The LIBNAME statement creates the libraries. However, the Excel files still need to be imported.
The rest of the program includes two macro programs that import the Excel data files into SAS data sets:
/*Step 3: Creating sas data sets*/
/*CDM datasets*/
%macro CDM (Domain= ) ;
PROC IMPORT DATAFILE= "&root./data/data_excel/CDM/&domain..xlsx"
DBMS=XLSX OUT= CDM.&domain ;
GETNAMES=YES;
RUN;
%mend CDM ;
%CDM (Domain = DEATH ) ;
%CDM (Domain = DM ) ;
%CDM (Domain = DS ) ;
%CDM (Domain = EX ) ;
%CDM (Domain = IE ) ;
%CDM (Domain = SPCPKB1 ) ;
The code here includes a macro program named CDM.
The CDM macro takes on one parameter named DOMAIN.
Inside the macro program is the proc import code.
This program allows you to systematically import the six Excel files (i.e. DEATH, DM, DS, EX, IE and SPCPKB1) into SAS.
Importing SDTM Data Files
The rest of the program includes another similar macro program.
It is used to import the SDTM data file named TA.
/*SDTM datasets*/
%macro SDTM (Domain= ) ;
PROC IMPORT DATAFILE= "&root./data/data_excel/SDTM/&domain..xlsx"
DBMS=XLSX OUT= SDTM.&domain ;
GETNAMES=YES;
RUN;
%mend SDTM ;
%SDTM (Domain = TA ) ;
As mentioned earlier, the program imports the data files into SAS:
We now have the SAS data sets ready to create the DM SDTM data set!
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |