**************************************************************************************************** * PROGRAM OVERVIEW **************************************************************************************************** * * PROGRAM: addcodestolabscodesmap.sas * Created (mm/dd/yyyy): 04/09/2021 * *-------------------------------------------------------------------------------------------------- * PURPOSE: Adds additional records as needed to the labscodesmap lookup file. This macro only * contains code to add the records and does not get executed when qrp_lookupfiles is * executed * * Program inputs: * - infolder.labcodesmap * * Program outputs: * - infolder.labcodesmap * * PARAMETERS: * Programming Notes: * * *-------------------------------------------------------------------------------------------------- * CONTACT INFO: * Sentinel Coordinating Center * info@sentinelsystem.org * ***************************************************************************************************; %macro addcodestolabcodesmap(); libname infolder ''; /*** empty file for variable lengths ***/ data labscodesvar; set infolder.labcodesmap(obs=1); call missing(code); run; %let pt_loc = E H I O U; /* code algorithm: - The first digit of this code is an "L" indicative of a lab code - digits 2-4 indicate a unique lab test name - digit 5 indicates a unique result type value (numeric or character) - digits 6-7 indicate a unique lab test subcategory - digit 8 represents a unique fasting indicator value - digits 9-10 indicate a unique specimen source - digits 11-12 indicate a unique patient location - digits 13-14 indicate the result unit */ /*** INF_A, INF_AB, INF_B ***/ %let labnames = INF_A INF_AB INF_B; %let sub_category = EIA IF NS PCR VTC; %let EIA = NPH NPWASH NSWAB NWASH OTHER THRT UNK; %let IF = BAL NPH NPWASH NSWAB NWASH OTHER THRT UNK; %let NS = BAL NPH NPWASH NSWAB NWASH OTHER THRT UNK; %let PCR = NPH NPWASH NWASH OTHER UNK; %let VTC = NPH NPWASH NWASH OTHER THRT UNK; data inf_ab_labs; set labscodesvar; %do l = 1 %to 3; d2= put(%eval(&l.+19),z3.); ms_test_name ="%scan(&labnames., &l.)"; result_type = 'C'; fast_ind = 'X'; ms_result_unit = ''; %do sc = 1 %to 5; %let ms_test_sub_category = %scan(&sub_category., &sc.); d6 = put(&sc., z2.); ms_test_sub_category = "&ms_test_sub_category."; %do sb = 1 %to %sysfunc(countw(&&&ms_test_sub_category.)); d9= put(&sb., z2.); %let specimen_source = %scan(&&&ms_test_sub_category., &sb.); specimen_source = "&specimen_source."; %do pt = 1 %to 5; d11 = put(&pt., z2.); pt_loc = "%scan(&pt_loc., &pt.)"; output; %end; %end; %end; %end; run; /*** INF_NS ***/ %let sub_category = NS PCR VTC; %let NS = UNK; %let PCR = NPH NPWASH NWASH OTHER UNK; %let VTC = NPWASH NWASH OTHER SPUTUM THRT UNK; data inf_ns_labs; set labscodesvar; ms_test_name ="INF_NS"; result_type = 'C'; fast_ind = 'X'; ms_result_unit = ''; d2= put(23,z3.); %do sc = 1 %to 3; d6 = put(&sc., z2.); %let ms_test_sub_category = %scan(&sub_category., &sc.); ms_test_sub_category = "&ms_test_sub_category."; %do sb = 1 %to %sysfunc(countw(&&&ms_test_sub_category.)); d9= put(&sb., z2.); %let specimen_source = %scan(&&&ms_test_sub_category., &sb.); specimen_source = "&specimen_source."; %do pt = 1 %to 5; d11 = put(&pt., z2.); pt_loc = "%scan(&pt_loc., &pt.)"; output; %end; %end; %end; run; /*** SARS_COV_2 ***/ %let sub_category = IA_RAP VTC PCR SEQ; %let IA_RAP = BAL NSWAB NWASH NPH NPWASH SPUTUM THRT; %let VTC = UNK; %let PCR = BAL NSWAB NWASH NPH NPWASH SPUTUM THRT UNK BLOOD PLASMA SERUM SR_PLS SALIVA; %let SEQ =SALIVABAL NSWAB NWASH NPH NPWASH SPUTUM THRT ; data sars_cov_2; set labscodesvar; ms_test_name ="SARS_COV_2"; result_type = 'C'; fast_ind = 'X'; ms_result_unit = ''; d2= put(24,z3.); %do sc = 1 %to 4; d6 = put(&sc., z2.); %let ms_test_sub_category = %scan(&sub_category., &sc.); ms_test_sub_category = "&ms_test_sub_category."; %do sb = 1 %to %sysfunc(countw(&&&ms_test_sub_category.)); d9= put(&sb., z2.); %let specimen_source = %scan(&&&ms_test_sub_category., &sb.); specimen_source = "&specimen_source."; %do pt = 1 %to 5; d11 = put(&pt., z2.); pt_loc = "%scan(&pt_loc., &pt.)"; output; %end; %end; %end; run; /*** Create CODE ***/ data inf_sars_labs; set inf_ab_labs inf_ns_labs sars_cov_2; Code = strip('L'||d2||'1'||d6||'1'||d9||d11||'01'); drop d2 d6 d9 d11; run; /*** Add to existing Labs Codes Mapping File ***/ data infolder.labcodesmap; set infolder.labcodesmap inf_sars_labs; run; proc datasets nowarn noprint lib=work; delete inf_: sars_cov_2 labscodesvar; quit; %mend addcodestolabcodesmap;