#!/bin/bash #
# Script : crtitlesds_win # Version : 1.3 # Author : Roland Rashleigh-Berry # Date : 20-Jul-2007 # Purpose : Production script to create the titles dataset from the # .titles files and the protocol dataset from the protocol.txt file # (uses SAS). # SubScripts : vtitles alltitles checktitles intnop getfields lisremap_win # SubMacros : %allocw %crprotds %crtitlesds # Notes : WINDOWS VERSION # Usage : crtitlesds_win #=============================================================================== # PARAMETERS: #-pos- -------------------------------description------------------------------- # N/A Do not supply any parameters #=============================================================================== # AMENDMENT HISTORY: # init --date-- mod-id ----------------------description------------------------ # rrb 23Feb07 Call %allocw macro # rrb 25Feb07 Use new fields # rrb 02Mar07 Use "&_ptlibref_.." instead of "der." # rrb 04Mar07 "getfields" script used # rrb 20Jul07 "lisremap_win" called #=============================================================================== # This is public domain software. No guarantee as to suitability or accuracy is # given or implied. User uses this code entirely at their own risk. #=============================================================================== # No parameters allowed if [ $# -gt 0 ] ; then echo "Error: (crtitlesds_win) Do not supply any parameters" 1>&2 exit 1 fi # strip out information returned by the "getfields" script client=$(getfields | cut -d/ -f1) office=$(getfields | cut -d/ -f2) drug=$(getfields | cut -d/ -f3) study=$(getfields | cut -d/ -f4) inc=$(getfields | cut -d/ -f5) # datetime datetime=$(date '+%e-%b-%Y at %H:%M:%S') # check the protocol.txt file is there if [ ! -f protocol.txt ] ; then echo "Error: File \"protocol.txt\", the protocol information file, is missing" 1>&2 fi # verify the titles files have a correctly matching program entry vtitles # create ALL.TITLES alltitles # Write SAS code to a temporary file cat > $HOME/crtitlesds_$$.sas << -----FINISH----- %allocw options validvarname=V7 nofmterr noovp; %crprotds(protocol.txt,&_ptlibref_..protocol) %crtitlesds(ALL.TITLES,&_ptlibref_..titles) proc sort nodupkey data=&_ptlibref_..titles(where=(type='T' and number=1 and sascode ne " ")) out=titles(keep=filename sascode); by filename; run; data _null_; set titles; file _fileout filevar=filename new notitles noprint; put @1 "/*"; put @1 "/ Program : " filename; put @1 '/ Author : Automatically generated by the "crtitlesds" script'; put @1 "/ Date : $datetime"; put @1 "/ Client : $client"; put @1 "/ Office : $office"; put @1 "/ Drug : $drug"; put @1 "/ Protocol : $study"; put @1 "/ Increment : $inc"; put @1 "/ Notes : Do not edit this member as it will get overwritten next time"; put @1 '/ "crtitlesds" is run. If you wish to change the code you must'; put @1 "/ change it in the .titles member."; put @1 "/==============================================================================*/"; put; put @1 sascode; run; -----FINISH----- # run the code sas -nosplash -nologo -icon -log "$HOMEW" -sysin "$HOMEW\crtitlesds_$$.sas" # List output file remappings using "lisfile:" entries lisremap_win # Check titles for errors checktitles # Check for missing sas programs intnop > ~/intnop_$$.tmp if [ -s ~/intnop_$$.tmp ] ; then echo "Warning: (crtitlesds) Titles entries exist for the following program(s) but no program yet exists" 1>&2 cat ~/intnop_$$.tmp 1>&2 fi rm -f ~/intnop_$$.tmp # tidy up rm -f $HOME/crtitlesds_$$.sas $HOME/crtitlesds_$$.log