Home > Expression Operators > Array Operators > #MPGEN

#MPGEN

Generates measurement period dates within the specified range#MPGEN is only available in Census Specification Data Default expressions.

Syntax:

a #MPGEN b

where:

a defines the type of measurement period: 1=annual, 2=semi-annual, 4=quarter, 12=month, 24=semi-month, 26=bi-week, 52=week

b is a parenthesized list of an even number of items, where each item is either a date or an array of dates: e.g., (7/4/2000, 1/1/2011) or (1/1/1999, 12/31/2020, 8/1/2000, 1/1/2031) or (b_dt, c_dt) or (b1_dt, e1_dt, b2_dt, e2,_dt, b3_dt, e3,_dt)). The odd items are the measurement period start date(s) and the even items are the stop dates for the calculation. Stop dates do not need to be measurement period dates; they are simply used as upper limits).

Notes:

Each date can be a scalar or a vector.  If the measurement period start date is a vector, the corresponding stop date can be either a scalar or a vector the same length as the measurement period start date.

If the first measurement period start date is greater than its corresponding stop date then no dates are generated.

Additional steps may be needed if the first measurement period date is after the 28th. For example, if you use 12 #MPGEN (1/31/2000, 1/1/2020) to generate monthly dates, what dates do you want generated for February (leap and non-leap years) and April, June, September, and November? No matter what the first measurement period date is, the generated dates are limited to the end of each month:

12 #MPGEN (1/31/2000, 1/1/2020) generates 1/31/2000, 2/29/2000, 3/31/2000, 4/30/2000, ..., 2/28/2001, ..., 12/31/2019

12 #MPGEN (1/30/2000, 1/1/2020) generates 1/30/2000, 2/29/2000, 3/30/2000, 4/30/2000, ..., 2/28/2001, ..., 12/30/2019

12 #MPGEN (1/29/2000, 1/1/2020) generates 1/29/2000, 2/29/2000, 3/29/2000, 4/29/2000, ..., 2/28/2001, ...,12/30/2019

If you want to generate end of measurement periods and your first measurement period date is not an end of month with 31 days, the easiest approach is to generate beginning of measurement periods and then subtract 1 day:

((12 #MPGEN (12/1/2000, 12/31/2020)) - 1) generates 11/30/1999, 12/31/1999, 1/31/2000, 2/29/2000, 3/31/2000, 4/30/2000, ..., 2/28/2001, ..., 12/31/2019

When determining the generated dates, the stop date is limited to today plus 50 years, and everything beyond the last calculation date is ignored.

Duplicate dates are dropped.

The generated dates are sorted in ascending order.


Examples:

12 #MPGEN (7/1/2000,12/31/2003) generates a vector of 42 dates: 7/1/2000, 8/1/2000, 9/1/2000, 10/1/2000 ..., 11/1/2003, and 12/1/2003

12 #MPGEN (7/4/2000,12/31/2003) generates a vector of 42 dates: 7/4/2000, 8/4/2000, 9/4/2000, 10/4/2000 ..., 11/4/2003, and 12/4/2003

1 #MPGEN (1/1/2000, 1/1/2004) generates a vector of 5 dates: 1/1/2000, 1/1/2001, 1/1/2002, 1/1/2003, 1/1/2004 (1/1/2004 is included because it's less than or equal to the 1/1/2004 stop date)

1 #MPGEN (1/9/2000, 1/1/2004) generates a vector of 4 dates: 1/9/2000, 1/9/2001, 1/9/2002, 1/9/2003 (1/9/2004 is not included because it's after the 1/1/2004 stop date)

1 #MPGEN (1/1/2000, 1/1/2004, 7/1/2002, 12/31/2005) generates a vector of 9 dates: 1/1/2000, 1/1/2001, 1/1/2002, 7/1/2002, 1/1/2003, 7/1/2003, 1/1/2004, 7/1/2004, 7/1/2005. Five dates are generated for [1/1/2000, 1/1/2004], and 4 dates are generated for [7/1/2002, 12/31/2005]. Then these 9 dates are combined and sorted in ascending order.

Use the status history to generate extra annual anniversary dates based each start event dates:

B_DT:= #START StatusHistory & ; event dates
N_DT:= 1 #START Status History & ; next event date
EVCODE:= #VALUE StatusHistory & ; event codes
IsStartEvent:= EVCODE #IN (10, 11, 12) & ; indicates whether it's a start event (1) or a stop event (0)
N2_DT:=  IsStartEvent*(N_DT+1) & ; multiplying the stop dates of stop events by zero, no dates will be generated for stop events


1 #MPGEN( B_DT. N2_DT)   ; because the stop dates for stop events (in B_DT) are zero (making those stop dates < their first measurement period dates),

; we'll only generate the anniversaries associated with the start events

; the above example assumes the decrement date is in the StatusHistory and the events are start/stop/start/stop/.../start/stop