/*=============================================================== * File: IQI_Prov.SAS * Title: MONAHRQ Utility Files for SAS; * * Description: * Reformats the SAS QI to WinQI style output; * for IQI Provider 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_Prov; *---------------------------------*; * get the variable names from the *; * output SAS data set produced by *; * SAS qi *; *---------------------------------*; proc contents data=outp3.&outfilp3. noprint out=&outfilp3.Vars ; run ; proc print data=&outfilp3.Vars ; var name label ; title3 "output from proc contents on &outfilp3. data set" ; run cancel ; data toNull ; set &outfilp3.Vars(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 cancel ; *--------------------------*; * 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" ; length keeplist $200 ; retain keeplist ' ' ; if first.qi then do ; put "Data " qi " ;" / " set outp3.&outfilp3. ; " / " QI='" QI "' ;" ; keeplist=trim(keeplist)||" QI hospid agecat sexcat paycat racecat _type_ "; 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" ; *----------------------------------*; * 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 ; *cancel ; *--------------------------------*; * 25Jul12tak: Keep '_type_' in *; * output data set. Increase *; * length of hospid to 20. *; *--------------------------------*; data _null_ ; set QIlist end=eof ; file "&wdir_.\&pgm_._temp2.txt" ; by qi ; if _n_=1 then do ; put "Data IQI_P3(rename=(charhospid=hospID)) ;" / " length Module $3 Ind_num $3 charhospid $20 ; " / " keep module Ind_num charhospid tpiqxx ppiqxx opiqxx obslci obsuci " / " epiqxx oe refpop rpiqxx lpiqxx upiqxx spiqxx _type_ ; " / " set " ; end ; put " " qi / ; if eof then do ; *-----------------------------------*; * 30Apr12tak: Steal logic from P3 in*; * SAS QI process for IQI to calc *; * Observed Se and CIs *; *-----------------------------------*; put " ; " / " drop hospid ; " / " charhospid=put(hospid,hospid.) ; " / " module=substr(compress(QI),1,3) ; " / " Ind_Num=substr(compress(QI),4) ; " / " if agecat=. and sexcat=. and paycat=. and racecat=. then do ;" / " if OPIQxx > . then do ; " / " OE=OPIQxx/EPIQxx ; " / " ObsSe=sqrt( (OPIQxx*(1-OPIQxx))/(PPIQxx) ) ; " / " ObsVr=ObsSe**2 ; " / " end ; " / " end ; " / " else do ; " / " if OPIQxx > . then do ; " / " OE=OPIQxx/EPIQxx ; " / " ObsSe=sqrt( (OPIQxx*(1-OPIQxx))/(PPIQxx) ) / EPIQxx ; " / " ObsVr=. ; " / " end ; " / " end ; " / " if OPIQxx > . then do ; " / " ObsLCI=OPIQxx-(1.96 * ObsSe) ;" / " ObsUCI=OPIQxx+(1.96 * ObsSe) ;" / " if . < ObsLCI < 0 then ObsLCI=0 ; " / " if ObsUCI > 1 then ObsUCI=1 ; " / " end ; " / " RefPOP=. ;" / " label " / " module='Module' " / " Ind_num='Indicator Number' " / " charhospid='Hospital ID' " / " TPIQxx='Observed Numerator' " / " PPIQxx='Observed Denominator' " / " OPIQxx='Observed Rate' " / " ObsLCI='Observed Conf Int. Low' " / " ObsUCI='Observed Conf Int. High' " / " EPIQxx='Expected Rate' " / " OE='O-E Ratio'" / " RefPOP='Reference Pop Rate' " / " RPIQxx='Risk Adjusted Rate' " / " LPIQxx='Risk Adj Conf Int. Low' " / " UPIQxx='Risk Adj Conf Int. High'" / " SPIQxx='Smoothed Rate' ;" / "run ;" ; end ; run ; proc format ; value hospid (default=20) .='TOTAL' ; *26Jultak: up to 20 characters for hospid; run ; %include "&wdir_.\&pgm_._temp2.txt" ; proc print data=IQI_P3 noobs ; id module ; title3 "New version of P3 output from Battelle SAS QI" ; run ; *--------------------------*; * Sort to move TOTAL to end*; * of each QI group. *; * 25Jul12tak *; *--------------------------*; proc sort data=IQI_P3 ; by module Ind_num descending _type_ ; 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 "&cd.\&pgm_._IQI_P3.csv" delimiter=',' DSD DROPOVER lrecl=32767; file "&pgm_._IQI_P3.csv" delimiter=',' DSD DROPOVER lrecl=32767; if _n_ = 1 then do; /* write column labels */ put "Module" ',' "Indicator Number" ',' "Hospital ID" ',' "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_P3 end=EFIEOD; format Module $3. ; format Ind_num $3. ; format hospID $20. ; format tpiqxx best12. ; format ppiqxx best12. ; format opiqxx best12. ; format obslci best12. ; format obsuci best12. ; format epiqxx best12. ; format oe best12. ; format refpop best12. ; format rpiqxx best12. ; format lpiqxx best12. ; format upiqxx best12. ; format spiqxx best12. ; if substr(Ind_num,1,1)='0' then Ind_num=substr(Ind_num,2) ; *11Jun12tak: Fix from S-3, Ed Hock ; do; EFIOUT + 1; put Module $ @; put Ind_num $ @; put hospID $ @; put tpiqxx @; put ppiqxx @; put opiqxx @; put obslci @; put obsuci @; put epiqxx @; put oe @; put refpop @; put rpiqxx @; put lpiqxx @; put upiqxx @; put spiqxx ; ; end; if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ if EFIEOD then call symputx('_EFIREC_',EFIOUT); run; /**//****************************//**/