smpl YTD
Posted: Wed Sep 11, 2019 2:05 am
Hi,
I have a series on monthly frequency.
I would like to set the sample so that I get the monthly data from the start of the year (january) until the current month summarized (or year to date) in the current year and the past five years.
For example, I want to know the number of houses sold from january until august in 2019. I also want to know the numbers of houses sold from january until august in 2018, 2017, 2016 etc. by setting the sample.
Is this possible?
I tried something like this, but it didn't work:
Mvh. Trym
I have a series on monthly frequency.
I would like to set the sample so that I get the monthly data from the start of the year (january) until the current month summarized (or year to date) in the current year and the past five years.
For example, I want to know the number of houses sold from january until august in 2019. I also want to know the numbers of houses sold from january until august in 2018, 2017, 2016 etc. by setting the sample.
Is this possible?
I tried something like this, but it didn't work:
Code: Select all
%thismonth=@datestr(@dateadd(@now, "0", "M"), "MM") 'returns current month
%startyear=@datestr(@dateadd(@now, "-4", "Y"), "YYYY") 'setting the startyear. 2015 in this case.
!s={%thismonth}-1 'this returns the number of the month with the last available observation.
smpl %startyear @now if @month< !s
Mvh. Trym