/*=============================================================== * File: IQI_Area.SAS * Title: MONAHRQ Utility Files for SAS; * * Description: * Reformats the SAS QI to WinQI style output; * for IQI Area level QIs; * * Prepared by Truven Health Analytics; * * VERSION 1.0, AUGUST 2012; * *===============================================================*/ options ls=120 ps=55 nocenter ; FILENAME CONTROL 'C:\PATHNAME\CONTROL_IQI.SAS'; *<===USER MUST modify; %include control ; %let pgm_=IQI_Area; *---------------------------------*; * get the variable names from the *; * output SAS data set produced by *; * SAS qi *; *---------------------------------*; proc contents data=outp3.iqa3 noprint out=iqa3Vars ; run ; proc print data=iqa3Vars ; var name label ; title3 "output from proc contents on iqa3 data set" ; run cancel ; data toNull ; set iqa3Vars(keep=name) ; if upcase(substr(name,3,2))='IQ' ; QI=compress("IQI"||upcase(substr(name,5,2))) ; Varclass=compress(substr(name,1,4)||'xx'); run ; proc sort data=toNull ; by qi Varclass name ; run ; proc print data=toNull ; title3 "List of variables to convert, sorted" ; run ; *--------------------------*; * grab location of SAS work*; * directory. *; *--------------------------*; %let wdir_ = %sysfunc(getoption(work)); %put &wdir_. is the working directory; *-----------------------------*; * Create a data step for each *; * QI and output variables from*; * Battelle SAS data set. *; *-----------------------------*; data _null_ ; set ToNull ; by qi Varclass name ; *file "&wdir_.\&pgm_._temp.txt" ; file "&pgm_._temp.txt" ; length keeplist $200 ; retain keeplist ' ' ; if first.qi then do ; put "Data " qi " ;" / " set outp3.iqa3 ; " / " QI='" QI "' ;" ; keeplist=trim(keeplist)||" QI marea agecat sexcat racecat "; end ; put " " varclass "=" name " ;" ; keeplist=trim(keeplist)||" "||varclass ; if last.qi then do ; put " keep " keeplist " ;" ; put "run ;" ; keeplist='' ; end ; run ; *-------------------------*; * Run the data steps. *; *-------------------------*; %*include "&wdir_.\&pgm_._temp.txt" ; %include "&pgm_._temp.txt" ; *----------------------------------*; * Create SAS steps to concatenate *; * all the QI specific data sets *; * into one. *; *----------------------------------*; proc sort data=toNull out=QIlist(keep=qi) nodupkey ; by qi ; run ; proc print data=QIlist ; title3 "Unique QIs in output data set from Battelle SAS qi" ; run ; data _null_ ; set QIlist end=eof ; file "&wdir_.\&pgm_._temp2.txt" ; by qi ; if _n_=1 then do ; put "Data IQI_A3(rename=(charArea=County)) ;" / " length Module $3 Ind_num $3 ; " / " retain module Ind_num charArea taiqxx paiqxx oaiqxx obslci obsuci " / " eaiqxx oe refpop raiqxx laiqxx uaiqxx saiqxx ; " / " keep module Ind_num charArea taiqxx paiqxx oaiqxx obslci obsuci " / " eaiqxx oe refpop raiqxx laiqxx uaiqxx saiqxx ; " / " set " ; end ; put " " qi / ; if eof then do ; *-----------------------------------*; * 30Apr12tak: Steal logic from A3 in*; * SAS QI process for IQI to calc *; * Observed Se and CIs *; *-----------------------------------*; put " ; " / " drop Marea ; " / " charArea=put(compress(Marea),$county.) ; " / " if compress(charArea)='' then charArea='TOTAL' ; " / " module=substr(compress(QI),1,3) ; " / " Ind_Num=substr(compress(QI),4) ; " / " if agecat=. and sexcat=. and racecat=. then do ;" / " if Oaiqxx > . then do ; " / " OE=Oaiqxx/Eaiqxx ; " / " ObsSe=sqrt( (Oaiqxx*(1-Oaiqxx))/(Paiqxx) ) ; " / " ObsVr=ObsSe**2 ; " / " end ; " / " end ; " / " else do ; " / " if Oaiqxx > . then do ; " / " OE=Oaiqxx/Eaiqxx ; " / " ObsSe=sqrt( (Oaiqxx*(1-Oaiqxx))/(Paiqxx) ) / Eaiqxx ; " / " ObsVr=. ; " / " end ; " / " end ; " / " if Oaiqxx > . then do ; " / " ObsLCI=Oaiqxx-(1.96 * ObsSe) ;" / " ObsUCI=Oaiqxx+(1.96 * ObsSe) ;" / " if . < ObsLCI < 0 then ObsLCI=0 ; " / " if ObsUCI > 1 then ObsUCI=1 ; " / " end ; " / " RefPOP=. ;" / " label " / " module='Module' " / " Ind_num='Indicator Number' " / " charArea='County' " / " Taiqxx='Observed Numerator' " / " Paiqxx='Observed Denominator' " / " Oaiqxx='Observed Rate' " / " ObsLCI='Observed Conf Int. Low' " / " ObsUCI='Observed Conf Int. High' " / " Eaiqxx='Expected Rate' " / " OE='O-E Ratio'" / " RefPOP='Reference Pop Rate' " / " Raiqxx='Risk Adjusted Rate' " / " Laiqxx='Risk Adj Conf Int. Low' " / " Uaiqxx='Risk Adj Conf Int. High'" / " Saiqxx='Smoothed Rate' ;" / "run ;" ; end ; run ; proc format ; value $county ''='TOTAL' ; run ; %include "&wdir_.\&pgm_._temp2.txt" ; proc print data=IQI_A3 noobs ; id module ; title3 "New version of A3 output from Battelle SAS QI" ; run ; *---------------------------------------*; * export to a csv *; *---------------------------------------*; %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ %let _EFIREC_ = 0; /* clear export record count macro variable */ data _null_; file "&pgm_._IQI_A3.csv" delimiter=',' DSD DROPOVER lrecl=32767; if _n_ = 1 then do; /* write column labels */ put "Module" ',' "Indicator Number" ',' "County" ',' "Observed Numerator" ',' "Observed Denominator" ',' "Observed Rate" ',' "Observed Conf Int. Low" ',' "Observed Conf Int. High" ',' "Expected Rate" ',' "O-E Ratio" ',' "Reference Pop Rate" ',' "Risk Adjusted Rate" ',' "Risk Adj Conf Int. Low" ',' "Risk Adj Conf Int. High" ',' "Smoothed Rate" ; end; set IQI_A3 end=EFIEOD; format Module $3. ; format Ind_num $3. ; format County $5. ; format taiqxx best12. ; format paiqxx best12. ; format oaiqxx best12. ; format obslci best12. ; format obsuci best12. ; format eaiqxx best12. ; format oe best12. ; format refpop best12. ; format raiqxx best12. ; format laiqxx best12. ; format uaiqxx best12. ; format saiqxx best12. ; do; EFIOUT + 1; put Module $ @; put Ind_num $ @; put County $ @; put taiqxx @; put paiqxx @; put oaiqxx @; put obslci @; put obsuci @; put eaiqxx @; put oe @; put refpop @; put raiqxx @; put laiqxx @; put uaiqxx @; put saiqxx ; ; end; if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ if EFIEOD then call symputx('_EFIREC_',EFIOUT); run; /**//****************************//**/