DON'T USE FOR NAT/REG PREPARATION (where year should be based on sale date)

recode_month(sale, month_range = 0:12)

Arguments

sale

data frame: Input sales table with at lest 2 variables: dot (transaction date in 'yyyy-mm-dd') and year (numeric license year)

month_range

numeric: A vector of months allowed in the output. Defaults to 0:12 since this is a common range of sales. Any months outside the range will be set to either the lowest values (for those less than the range) or the highest value (for those over). This prevents unusual sale months from appearing in results.

Value

Returns a sales table with a standardized 'month' variable and prints a validation output.

Details

The output month variable captures transaction year and month in one metric. The month number is relative to the license year: 1 = Jan, 2 = Feb, etc, for current/future years and 0 = Dec, -1 = Nov, ..., for previous years.

See also

Other functions for standardizing state license data: recode_state, state_abbreviations

Examples

# For Southwick analysts: see data preparation scripts