BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Pong
Calcite | Level 5

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.

 

Untitled2.png

I would appreciate your help.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.

View solution in original post

2 REPLIES 2
Reeza
Super User

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.

udo_sas
SAS Employee

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

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

Multiple Linear Regression in SAS

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.

Discussion stats
  • 2 replies
  • 1932 views
  • 0 likes
  • 3 in conversation