**************************************************************************************************** * PROGRAM OVERVIEW **************************************************************************************************** * * PROGRAM: ms_extractmeds.sas * * Created (mm/dd/yyyy): 07/31/2014 * Last modified: 07/31/2014 * Version: 1.0 * *-------------------------------------------------------------------------------------------------- * PURPOSE: * This program pre extracts raw diagnosis or procedure claims based solely on code match. This is * useful to use as a pre-extraction to avoid claim duplication; * * Program inputs: * -dataset to extract records from * -dataset containing the list of codes to extract * * Program outputs: * -dataset containing the extracted records * * PARAMETERS: * -datafile = Name of the dataset to extract records from. * -datacode = Name of the variable containing the codes. * -DataCodeType = Name of the variable containing the CodeType. * -lookfile = Name of the sas dataset containing the list of codes to extract. The name of the variable * containing the codes must be called "code" and the one containing the codetype must be * called "codetype". * -outfile = Name of the output dataset containing the extracted records. * -ExtraVars = To add extra variables to initial proc sort nodupkey. * * Programming Notes: * * * *-------------------------------------------------------------------------------------------------- * CONTACT INFO: * Mini-Sentinel Coordinating Center * info@mini-sentinel.org * *-------------------------------------------------------------------------------------------------- * CHANGE LOG: * * Version Date Initials Comment (reference external documentation when available) * ------- -------- -------- --------------------------------------------------------------- * mm/dd/yy * ***************************************************************************************************; %MACRO ms_extractmeds(datafile=, datacode= , DataCodeType=, lookfile=, outfile=, ExtraVars=); %put =====> MACRO CALLED: ms_extractmeds v1.0; %ISDATA(dataset=&lookfile.); %IF %EVAL(&NOBS.>=1) %THEN %DO; proc sort nodupkey data=&lookfile. out=_list; by code codetype &ExtraVars.; run; proc sql noprint; create table &outfile. as select claim.*, codes.* from &datafile. as claim, _list as codes where codes.code = compress(claim.&datacode.,'.') and codes.CodeType = claim.&DataCodeType.; quit; %END; %ELSE %DO; data &outfile.; set &datafile.(obs=0) &lookfile.(obs=0); run; %END; proc datasets library=work nolist nowarn; delete _list; quit; %put NOTE: ********END OF MACRO: ms_extractmeds v1.0********; %MEND ms_extractmeds;