/*-------------------------------------------------------------------------------------*\ | PROGRAM NAME: | | scdm_data_qa_review_inpatientpharmacy.sas | | | |---------------------------------------------------------------------------------------| | PURPOSE: | | The purpose of this program is to perform data quality checks on the Ipharmacy | | table. | |---------------------------------------------------------------------------------------| | PROGRAM INPUT: | | see 00.0_scdm_data_qa_review_master_file.sas | | | | PROGRAM OUTPUT: | | see Workplan PDF | |---------------------------------------------------------------------------------------| | CONTACT: | | Sentinel Coordinating Center | | info@sentinelsystem.org | \*-------------------------------------------------------------------------------------*/ *-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-; * PLEASE DO NOT EDIT BELOW WITHOUT CONTACTING THE SENTINEL OPERATIONS CENTER ; *-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-; /*-------------------------------------------------------------------------------------*/ /* START Level 2 Flags */ /*-------------------------------------------------------------------------------------*/; * All IRX L2 flags are coded within the lkp_all_flags lookup table and do not require additional program code; %let level=2; %level2; /*-------------------------------------------------------------------------------------*/ /* START Level 3 Data */ /*-------------------------------------------------------------------------------------*/ %let level = 3; %let qa_table= ; %macro get_qa_table ; %if &do_partitions and not %eval(&module in &tabid_exc) %then %do ; data t_view /view=t_view ; set qadata.&&&module.table.: (keep=RxADate RxATime RxRoute RxDose) ; run; %let qa_table = t_view ; %end ; %else %do; %let qa_table = qadata.&&&module.table (keep=RxADate RxATime RxRoute RxDose) ; %end; %mend; %get_qa_table ; proc sql noprint; create table dplocal.&module._temp as select * , count(*) as n from &qa_table group by 1,2,3,4 ; quit; %remove_labels(dplocal, &module._temp) proc sql noprint; create table dplocal.&module._temp_ym as select put(RxADate,yymmd.) as YearMonth , rxroute , rxdose , sum(n) as n from dplocal.&module._temp (keep=rxadate rxroute rxdose n) group by 1,2,3 ; quit; proc sql noprint; create table dplocal.&module._temp_dates as select rxadate , sum(n) as n from dplocal.&module._temp (keep=rxadate n) group by 1 ; quit; %date_percentiles (libin=dplocal, dsin=&module._temp_dates, libout=dplocal, dsout=date_dist_&module., vars=rxadate); * 2.2.4 Frequency of records stratified by route of administration and year-month; proc sql noprint; create table msoc.&module._l3_rxroute_ym as select YearMonth , rxroute , sum(n) as count format=comma15. from dplocal.&module._temp_ym (keep=yearmonth rxroute n) group by 1,2 ; quit; * 2.2.5 Frequency of records stratified by dosage administered and year-month; proc sql noprint; create table msoc.&module._l3_rxdose_ym as select YearMonth , rxdose , sum(n) as count format=comma15. from dplocal.&module._temp_ym (keep=yearmonth rxdose n) group by 1,2 ; drop table dplocal.&module._temp_ym ; quit; * 2.2.1 Frequency of records stratified by year-month values; proc sql noprint; create table msoc.&module._l3_rxadate_ym as select yearmonth , sum(count) as count format=comma15. from msoc.&module._l3_rxroute_ym (keep=yearmonth count) group by 1 ; quit; proc sql noprint; create table dplocal.&module._temp_time as select put(RxADate,yymmd.) as YearMonth , hour(rxatime) as hour , rxatime , sum(n) as n from dplocal.&module._temp (keep=RxADate RxATime n) group by 1,2,3 ; drop table dplocal.&module._temp ; quit; * 2.2.2 Frequency of records stratified by hour of the day; proc sql noprint; create table msoc.&module._l3_rxatime_hour as select hour format = z2. length=3 , sum(n) as count format = comma15. from dplocal.&module._temp_time (keep=hour n) group by 1 ; quit; * 2.2.3 - Statistical distribution of dispensing time of day by year-month; proc means nolabels nonobs data=dplocal.&module._temp_time missing StackODSOutput n mean std min p1 P5 P25 median P75 P95 p99 max; var rxatime; class yearMonth; ods output summary= msoc.&module._l3_rxatime_ym_stats (drop=_: variable rename=(stddev=Std)); run; proc datasets library=msoc nolist nodetails nowarn; modify &module._l3_rxatime_ym_stats; format n comma15. mean std p: min max median HHMM5.; quit; %macro get_qa_table ; %if &do_partitions and not %eval(&module in &tabid_exc) %then %do ; data t_view /view=t_view ; set qadata.&&&module.table.: (keep=patid encounterid rxadate ndc) ; run; %let qa_table = t_view ; %end ; %else %do; %let qa_table = qadata.&&&module.table (keep=patid encounterid rxadate ndc) ; %end; %mend; %get_qa_table ; proc sql noprint; drop table dplocal.&module._temp_time ; create table dplocal.&module._temp as select put(RxADate,yymmd.) as YearMonth , patid , encounterid , ndc , count(*) as n from &qa_table group by 1,2,3 ; quit; %remove_labels(dplocal, &module._temp) * 2.2.6 - Frequency of records stratified by NDC value; proc sql noprint; create table msoc.&module._l3_ndc as select ndc , sum(n) as count format=comma15. from dplocal.&module._temp (keep=ndc n) group by 1 ; quit; /* number of dispensings per patid per encounter by year-month */ proc sql noprint; create table dplocal.&module._rx_pat_enc_ym as select patid, encounterid, yearmonth, sum(n) as n from dplocal.&module._temp (keep=patid encounterid yearmonth n) group by 1,2,3 ; drop table dplocal.&module._temp ; quit; /* number of dispensings per patid by year-month */ proc sql noprint; create table dplocal.&module._rx_pat_ym as select patid, yearmonth, sum(n) as n from dplocal.&module._rx_pat_enc_ym (keep=patid yearmonth n) group by 1,2 ; quit; /* 2.2.7 level 3