27 August 1993 c:/wp51/macros/count.mac Monthly count macro This macro gives a monthly count of the number of admissions, discharges and hospital days over a specified number of months from a specified start date. It can be used to gather this information for individuals (id_variable=phin91) or for hospitals (id_variable=hosp). The initial dataset will have one or more records per person but the output dataset will contain only one record per person retaining the original variables and, additionally, the monthly counts and a total for the number of admissions, discharges and hospital days over the entire study period. To use: 1. Add "options implmac" to the program to call the macro. 2. Sort by id_variable (unless data is already sorted by this variable). 3. Invoke macro: %cntmon(id_variable, start_year_&_month, end_year_&_month, admit_date, discharge_date, coverage_start_date, coverage_end_date); if last.id_variable; run; Example 1:%cntmon(phin91,9003,9203,ndtadmit,ndtsep,covsta,ndtdth); The above will count the number of admissions, separations and days in hospital for each (covered) individual in a cohort. The study period is from March 1990 to March 1992. Example 2:%cntmon(hosp,9003,9203,ndtadmit,ndtsep,covsta,ndtdth); The above will count the number of admissions, separations and days in hospital for each hospital. The study period is from March 1990 to March 1992. NOTE: All variables must be represented in order for the macro to work. However, in this case, the last two are not appropriate: dummy variables should be set up such that all observations "are covered" over the entire study period ie: coverage_start_date is set on all records as a date that is earlier than the start of the study and coverage_end_date is set on all records as a date that is later than the end of the study. NOTE: 1. All the variables listed in brackets after the %cntmon statement must be represented in order for the macro to work. If a variable is not present then a "dummy" variable should be set up (eg: coverage variables in the attached example). 2. Start_year_&_month or end_year_&_month should be specified as YYMM ie: 9004 for April, 1990. 3. Dates should be SAS dates. There should be no missing values for any of the date variables. 4. The coverage_start_date and coverage_end_date variables allow you to differentiate between a month where an individual had no contact with a hospital but was registered with the health care plan and one where the individual was not covered (ie: had left the province or died). If the former were the case, any month where there were no admissions, separations or days in hospital the variables generated by the macro would have a value of zero. If the latter were true, the variables produced by the macro would be represented as missing values ie: "." 5. The following variables are produced by the macro for each study month: a_YYMM a count of the number of admissions for month YYMM s_YYMM a count of the number of discharges for month YYMM d_YYMM a count of the number of days in hospital for month YYMM The following totals are produced over the whole study period: tot_day the total number of days spent in hospital tot_adm the total number of admissions tot_sep the total number of admissions NOTE: An individual whose stay starts prior to the study period and extends beyond its endpoint will show no admissions or separations but tot_day will equal the number of study days. Similarly, if the hospital stay for an individual extends across an entire month (ie: admitted May 21st 1992 and discharged July 2nd 1992) there will be no admissions or separations for the month of June, but the "days" variable will show that there were 30 in patient days in June (ie: a_9206=0, s_9206=0, d_9206=30). 6. The macro can be used more than once in a single datastep in order to obtain counts over different time periods. However, the intervals should not overlap ie: %cntmon(phin91,9003,9203,...); - will generate counts for March '90 to March '92 %cntmon(phin91,9303,9503,...); - will generate counts for March '93 to March '95