Hi,
I'm new to this program.
try to use proc esm but got this error.
it's work fine with other data so I don't know why.
data TS.Tax;
input Year Million;
datalines;
2005 6955.97
2006 7208.05
2007 7316.21
2008 7651.33
2009 7746.77
2010 8980.54
2011 10249.16
2012 11944.38
2013 12603.92
2014 12436.56
2015 13962.79
;
proc esm data=TS.Tax
outfor=TS.outTax outstat=TS.statTax
back=0 lead=5 print=all plot=all;
id year interval=year;
forecast Million;
run;
ERROR: Duplicate time interval found at observation number 2 in the data set TS.TAX, according
to the INTERVAL=YEAR option and the ID variable values. The current ID is Year=2006 and
the previous is Year=2005, which are within the same YEAR interval.
Check that INTERVAL=YEAR is correct for this data set, and that the ID variable Year
contains SAS date or datetime values that correctly identify the observations.
I would appreciate your help.
Thank you
Year isn't a SAS date or date time variable which is what's expected.
From the documentation:
The ID statement names a numeric variable that identifies observations in the input and output data sets. The ID variable’s values are assumed to be SAS date or datetime values. In addition, the ID statement specifies the (desired) frequency associated with the time series.
Convert 'year' into a SAS date and it will work. You can use MDY() function and set it to Jan 1 of each year.
Year_SAS = MDY(1,1, year);
Format year_sas year4.;
Then replace year with year_sas in your code.
Year isn't a SAS date or date time variable which is what's expected.
From the documentation:
The ID statement names a numeric variable that identifies observations in the input and output data sets. The ID variable’s values are assumed to be SAS date or datetime values. In addition, the ID statement specifies the (desired) frequency associated with the time series.
Convert 'year' into a SAS date and it will work. You can use MDY() function and set it to Jan 1 of each year.
Year_SAS = MDY(1,1, year);
Format year_sas year4.;
Then replace year with year_sas in your code.
Hello -
Little known feature of ESM - from documentation: " If an ID statement is not specified, the observation number, with respect to the BY group, is used as the time ID.". With other words, this code will work too:
proc esm data=ts.Tax
outfor=ts.outTax outstat=ts.statTax
back=0 lead=5 print=all plot=all;
forecast Million / model=damptrend ;
run;
I took the liberty to change the default model (simple ESM) to a damp trend model, which seems to be more appropriate for your data.
Thanks,
Udo
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.