/***************************************************************************************************
Macro Name: DMES_V1

Function:
This program will be used to apply the DMES System & DMES Types to HCPCS codes

Author: Matt Hall, PhD; Children's Hospital Association

Date: August 18, 2023

Load macro:

%INCLUDE "\path\DMES_GROUPER_v1.sas";

Call statement:

%DMES_V1(dt_in,dt_out,pr);

Parameter definitions:

   dt_in:  SAS input data set containing patient id and a single HCPCS code
   dt_out: SAS output data set containing all input data and new created DMES SYSTEM & DMES TYPE
   pr: variable name for the HCPCS code
***************************************************************************************************/

*PATHNAME specifies the location of the Excel file "Hotz_HCPCS_DMES_System_8.15.23.xlsx";

%LET PATHNAME=\path;  *<===USER MUST modify;

/*Import DMES Excel*/
PROC IMPORT FILE="&PATHNAME.\Hotz_HCPCS_DMES_System_8.15.23.xlsx" DBMS=xlsx OUT=DMES REPLACE;
	SHEET="HCPCS DME Full Categorization";
RUN;
%MACRO DMES_V1(dt_in,dt_out,pr);
	PROC SQL;
		CREATE TABLE &dt_out. AS
		SELECT &dt_in..*, DMES.*
		FROM &dt_in. LEFT JOIN DMES(KEEP=HCPCS_Code DMES_System DMES_Type)
		ON &dt_in..&pr.=DMES.HCPCS_Code;
	QUIT;
%MEND;
