Professional Documents
Culture Documents
A Menu-Driven System
A Menu-Driven System
A Menu-Driven System
In clinical trials, patient profiles are usually requested by medical writers and data managers. Medical writers need them to
write narratives about adverse reactions to trial drugs and their relationships with concomitant medications, pre-existing
medical conditions, vital signs, and lab results. Data managers need them to resolve data issues. The process is considered
one of the most complicated ones, since it involves gathering all information for each subject. Furthermore, it consumes
valuable project time in investigating case report forms, contents of datasets and code lists, programming and validation.
Unfortunately, the same process is usually repeated for new projects.
We present here a user-friendly menu-driven system using SAS® macros. The macros will do the investigative work,
identifying datasets, variables, labels, and formats. You need to provide only 3 pieces of information: where the data is
located, subject randomization dataset, and subject unique ID variable. Now, relax and let the macros do the hard work.
KEYWORDS
Profile, Patient Profile, Subject Profile, Listing.
AUDIENCE
Database Professionals, Programmers, Statisticians and Medical Writers with limited or advanced SAS experience.
USER FRIENDLY
Usually, we get impressed by software demos and when we try to get them to work, we start looking at “ HELP,” searching
for “ What to do if you get lost.” What we present here is exactly what we described. It requires minimum input and data
specifics (if any). The “ intelligent” macros will process everything, ignore peculiar files and carry on processing. The interactive
window simplifies the input process for non-SAS users.
STANDARDIZATION
Although following some simple consistent rules while designing Case Report Forms (CRF) and Databases simplify the
process, the program assumes those standards have not been implemented. We will use the word ‘ Panel’ to indicate a data
entry screen that has been extracted into a SAS dataset. A panel may contain a single CRF, part of it, or more than one CRF.
Standard ID variables should have the same Names and Formats in All panels. This applies also to studies within the
same project. Examples of the ID variables are SPONSOR, PROTOCOL, STUDY, SITE/ CENTER/ INVESTIGATOR No.,
SUBJECT No., SUBJECT INITIALS, VISIT No., VISIT DATE, CRF Name, PAGE No., and RECORD No. Good and consistent
CRF and Database design will create the same ID fields (even if they are not part of the CRF) with a blank/missing value.
Examples of this are the Visit Number and Date. Although they are important in ordering the events chronologically,
sometimes they are not entered. In the case of Adverse Events panel, the importance is on the Start and End Dates of the
event. Subject Initials must be 3 Characters. If the middle initial is missing, use a dash ‘ -’ instead. To unify the European and
American dates, all Dates must be Y2K compliant in the form ddmmmyyyy.
Only raw data files have to be extracted in the raw data directory. Preferred term medical dictionaries, standard drug
names, and lab normal ranges are not part of the CRFs and should not be saved with subjects’ raw data. Medical and drug
dictionaries and lab ranges have to be applied to the relevant datasets before processing.
Currently, Clinical Data Interchange Standards Consortium (CDISC ® ) have been implemented at many pharmaceutical
organizations. Those standards specify in full details dataset and variable names, in addition to their type, labels, and formats.
LIBRARIES DEFINITION
The macros assume the following default directory hierarchy structure. They will define the following libraries to read and
save the Raw, Formats and Output files (based on user input). Library Out is used to save the LST and LOG. If the input data
is in a different SAS version, use V8 or V6 in the library definition statement. If you do not specify the version, SAS reads
datasets in any version, but in output it assumes the current version under which the program is executing.
1
MACRO COMPILING
In order to compile a macro, use the following statements before the macro definition. This will create the catalog file
SASMACR.SAS7BCAT (under Microsoft Windows®), provided that you use the STORE option in the macro definition. In order
to invoke the compiled macro, the same statements are used in the calling program to define where the compiled macro is
located. Using the compiled macro preserves the generic code and eliminates the need for using %INC to include the source
code. The macro library MAC needs to be defined only ONCE in a session. A macro library cannot be redefined or cleared
until the end of the SAS session.
PURPOSE OF PROGRAM
To capture all information for all subjects in a database and produce a report separated for each subject. The report has
the option of printing descriptive values rather than coded values for variables. The report may be produced for a selected
subset (of studies, sites, subjects, etc.). The program allows the user to apply project specifics.
DESCRIPTION
The process is automated through a set of 6 generic macros and 1 specific macro.
Patient Profile
Access Date & Time : weekday, ddmmmyy, hh:mm
Save LST/LOGat:__________________________________________________
[ Blank: Display Only ]
2
• Required: Raw Datasets Directory location.
Define LIBNAME RAW, using raw datasets location.
• Optional: Output Directory to save the LST and LOG. (Blank: Display only, you save it).
The system will define Line Length and Page Size, if Output location is entered.
• Optional: Key Sort Variables for processing. (Blank: use variables according to their order in database).
Key sort variables must be separated by at least one space.
Key sort variables must exist in All panels. They will be used in processing and listing output in the requested order.
If Key Sort Variables are not provided, the system will sort by variables based on their Order in the database.
• Use the following if you want to clear the Display Window each run.
3
• OR: For repeated runs, directly give the macro variable values to the Display Window.
%MACRO specific ;
%MEND specific ;
%profile ;
• If the specifics for datasets are too many, it is recommended that you create a new data directory and save the datasets in
it after modifying with simple data steps.
%MACRO specific ;
%IF %UPCASE (&pnl)= ADVEV %THEN %DO; %LET srt=&orgsrt visitnum recno; %END ;
%ELSE %IF %UPCASE (&pnl)= PHYSEX %THEN %DO; %LET srt=&orgsrt bodsys ; %END ;
%ELSE %IF %UPCASE (&pnl)= VITALS %THEN %DO; %LET srt=&orgsrt dtvisit tmvisit; %END ;
%ELSE %DO; %LET srt=&orgsrt ; %END ;
%MEND specific ;
4
DETAILS OF PROFILE SET OF GENERIC MACROS
Input None.
Output Tidy up, Definition of Global REALTIME and LINE Macro Variables,
Footnotes, and System Options, including PAGENO=1.
DATA _NULL_ ;
CALL SYMPUT('realtime' , TRIM (LEFT (PUT ( TODAY () , WEEKDATE3. ))) || ',' ||
TRIM (LEFT (PUT (DATETIME () , DATETIME13.))) ) ; RUN ;
FOOTNOTE1 "&line" ;
FOOTNOTE2 "&SYSSCPL * %UPCASE(&dir\prog\&prg) * &realtime * [BY: &SYSUSERID]" ;
%MEND setup ;
• Get all library member names. Keep necessary fields. Exclude any panels provided by the EXC user option, if any.
DATA memname ;
SET memname ;
BY memname varnum ;
IF LAST.memname ;
%IF &exc NE %STR ( ) %THEN %DO ;
IF INDEX(UPCASE(TRIM(LEFT("&exc")))||" ",UPCASE(COMPRESS(memname))||" ")>0 THEN DELETE ;
%END ; RUN ;
5
• Create a global macro variable NMEMBER. This is the number of panels that will be processed.
%GLOBAL nmember ;
DATA memname ;
SET memname END=eof ;
BY memname NOTSORTED ;
memno+1 ;
IF eof THEN CALL SYMPUT ( 'nmember' ,TRIM (LEFT (PUT (memno,3.)))) ;
LABEL memno = 'Member Number'
memname = 'Member Name'
varnum = 'Variables Total'
nobs = 'Records Total' ; RUN ;
• Give sequence number MEMNO for each member. Create global macro variables MEMNOn, which contain the
MEMNAMEn. Create and set macro variables RECORDn to 0.
DATA memname ;
RETAIN memno memname varnum nobs ;
SET memname ; RUN ;
DATA _NULL_ ;
SET memname ;
CALL SYMPUT( 'memno' || LEFT (PUT (memno,3.)) , TRIM (memname)) ; RUN ;
%MEND nmember ;
Input SBJ subject identifying dataset (such as Randomization, Demographics). It must contain All subjects
Output NSUBJECT macro variable, for the total number of subjects to be processed.
SBJNOn macro variables, which contain the unique ids SIDn.
• Get all subject unique IDs. Subset for only those subjects provided by the SUB subset user option, if any.
• Create a global macro variable NSUBJECT. This is the number of subjects that will be processed.
%GLOBAL nsubject ;
DATA sbj ; SET sbj END=eof ;
BY &sid NOTSORTED ;
sbjno+1 ;
IF eof THEN CALL SYMPUT ( 'nsubject' , TRIM (LEFT (PUT (sbjno,4.)))) ;
label sbjno = 'Subject Sequence'
&sid = 'Subject Unique ID' ; RUN ;
6
• Give sequence number SBJNO for each subject. Create global macro variables SBJNOn, which contain the SIDn.
%MEND nsubject ;
• Get panel, drop any variable provided by the DRP user option, if any. Create a variable PANEL(contains dataset name).
Sort by variables according to their order in database, or provided by the key SRT user option, if any.
DATA &pnl ;
RETAIN panel ;
SET &pnl ;
LENGTH panel $8 ;
panel = %upcase ("&pnl") ;
LABEL panel = 'Panel' ;
%IF &drp NE %STR( ) %THEN %DO ; DROP &drp ; %END ;
RUN ;
• Create a Record Sequence Number that will identify the record if output is spread among multiple pages.
Order and Print all the variables and values for this panel.
DATA pnl ;
RETAIN rec panel %IF &srt NE %STR( ) %THEN %DO ; &srt %END ;;
SET ;
BY panel %IF &srt NE %STR( ) %THEN %DO ; &srt %END ;;
Rec = _N_ ;
LABEL rec = 'Rec ID' ; RUN ;
%MEND getprof ;
7
(7) GETALL macro ( libname) Main Analysis Loop
• Get All requested panels and process for all subjects.
• Invoke NMEMBER and NSUBJECT macros. Get all panels, and apply specifics for all or for each (if any).
Create a macro variable for PANEL (contains dataset name) and RECORDn (total records) to be used in the title.
Print a log message indicating the currently processed Subject ID, Panel Name, and Total Records.
%nmember (&libname) ;
%nsubject (&sbj) ;
%getprof (&&memno&j) ;
DATA _NULL_;
SET pnl NOBS=nobs ;
%LOCAL zero ; %LET zero = %STR (0) ;
IF nobs GT 0 THEN CALL SYMPUT('record'||LEFT(PUT(&j,3.)),TRIM(LEFT(nobs))) ;
ELSE CALL SYMPUT('record'||LEFT(PUT(&j,3.)),TRIM(LEFT(&zero))); RUN ;
%PUT ** &&sbjno&i &&memno&j &&&record&j ** Subject/ Panel/ Total Records ***** ;
%END ;
%END ;
• Print an overall summary of the processed panels for all subjects, including panel name, total variables and number of
records processed.
%MEND getall ;
Input None.
Output Full report of profile for each panel and an overall summary.
8
%MACRO profile / STORE DES='Display Input Window & Process' ;
• Invoke SETUP macro, display Profile Window.
%GLOBAL dat sbj sid fmt out sub exc drp srt orgdrp orgsrt ;
%setup ;
%WINDOW profile
#36 @23 "Press" C=red @29 "RETURN" A=underline C=orange @36 "to continue." C=red ;
• Display the user interface, conditionally process the window Input Options and Execute Macros. Exit if errors.
%DISPLAY profile ;
%* More SAS statements to read the input from user window and conditionally process them;
CONCLUSION
This macro will list patient profile extracted from all available datasets. It is very simple to use and has a user interface in
the form of an input window, which is helpful for non-SAS users as well as for the experts. The user will be in control of
specifics for each project. The set of generic macros will do the rest. Due to the huge size of printed output, the big plus here is
the option for sub-setting for one individual subject or a group of subjects, to reduce unnecessary output. This will run for any
project or any client. The macros are Generic and do not need to be modified for specific projects.
9
VALIDATION
The macros and sample calls have been fully tested and validated using SAS Version 8.02 software on Microsoft
Windows ® platform.
REFERENCES
AUTHOR
Adel has been a SAS user for 20 years. He worked as Independent Consultant, Sr. Statistical Programmer and Director of
Systems; at major pharmaceutical companies, clinical research organizations, and universities, teaching SAS to faculty and
students. His special achievements include Generic Macros, Edit Checks, Database Design, Menu-Driven Systems and
Optimization Techniques.
Adel has BS in Mathematics, Graduate Diploma in Systems Design, MS and M.Phil. in Computer Science from
Nottingham University, UK.
CONTACT
Your comments and questions are welcomed. The author can be contacted at:
Adel Fahmy, EMS: Adel.Fahmy@netzero.net Voice: (732) 422 6651
COPYRIGHTS
SAS® and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute
Inc. in the USA and other countries. ® indicates USA registration. Windows® is a registered trademark of Microsoft Inc. Other
brand and product names are registered trademarks or trademarks of their respective companies.
10
APPENDIX 1
Following is a sample output for a single subject that includes some datasets and the Overall Summary
for All subjects.
Page 1
________________________________________________________________________________________________________
Page 2
________________________________________________________________________________________________________
Rec AE CTC AE AE AE AE
ID SEVERITY SCALE RELATIONSHIP SERIOUS OUTCOME ONGOING ACTION
11
Page 3
________________________________________________________________________________________________________
Rec PATIENT PATIENT CRF PAGE VISIT VISIT DATE OF PRIMARY REASON
ID Panel ID INITIALS NUMBER NUMBER DATE ASSESSMENT FOR ENDING STUDY
Page 8
________________________________________________________________________________________________________
1 ADVEV 23 18
2 CONMED 23 71
3 DEMOG 15 5
4 EOS 17 5
5 PHYSEX 46 12
6 VITALS 20 8
7 WHO 11 8
=======
127
________________________________________________________________________________________________________
WIN_PRO * C:\_RESEARCH\PROFILE\PROG\PROFILE * Sun,12FEB06:15:30 * [By: adelf]
12