%smpl = @pagesmpl

' The first quarter for which we'll generate data.
' This determines the equation used to find the quarterly growth rate.
%tmp = @otods(1)
!start_quarter = @datepart(@dateval(%tmp), "Q")

' Equation text is set assuming that the current observation (lag 0) is the observation preceding the start quarter.
' This assumption will be fulfilled before estimating the equation below.
if !start_quarter = 1 then
	%eq_text = %1 + " / 100 + 1 = " + %0 + " * (c(1) + c(1)^2 + c(1)^3 + c(1)^4) / @movsum(" + %0 + ", 4)"
else if !start_quarter = 2 then
	%eq_text = %1 + " / 100 + 1 = " + %0 + " * (1 + c(1) + c(1)^2 + c(1)^3) / @movsum(" + %0 + "(-1), 4)"
else if !start_quarter = 3 then
	%eq_text = %1 + " / 100 + 1 = (" + %0 + "(-1) + " + %0 + " * (1 + c(1) + c(1)^2)) / @movsum(" + %0 + "(-2), 4)"
else
	%eq_text = %1 + " / 100 + 1 = (" + %0 + "(-2) + " + %0 + "(-1) + " + %0 + " * (1 + c(1))) / @movsum(" + %0 + "(-3), 4)"
endif
endif
endif

' Set the sample to the single observation preceding the start quarter.
smpl {%tmp}-1 {%tmp}-1

' Estimate the equation to find the quarterly growth rate.
%e = @getnextname("auxeq")
equation {%e}.ls {%eq_text}

' Fill in the data.
smpl {%smpl} 
{%0} = c(1) * {%0}(-1)

