The TSMODEL Procedure
Comparison of the TSMODEL and TIMEDATA Procedures
The syntax of the TSMODEL procedure is similar to the syntax of the TIMEDATA procedure in SAS/ETS software. For more information about PROC TIMEDATA, see SAS/ETS User's Guide.
PROC TSMODEL requires that you specify CAS tables for all input data and all output data. Unlike PROC TIMEDATA, no actual processing of the time series data occurs in PROC TSMODEL; data in PROC TSMODEL are processed in the CAS session that is associated with the CAS librefs that you specify in the PROC TSMODEL statement.
Like PROC TIMEDATA, PROC TSMODEL supports auxiliary input tables, which you specify in the AUXDATA= option. However, PROC TSMODEL requires that either all or none of the BY variables are present in an AUXDATA= table. No partial BY group matching for the AUXDATA= tables is supported at this time.
A simple example provides insight about the relative ease of moving from PROC TIMEDATA to PROC TSMODEL. Consider the following PROC TIMEDATA example, which rescales the Sale and Price variables for each of the Product BY groups:
proc timedata data=mylib.pricex
outsum=mylib.pricexsum
outarray=mylib.pricexoa
outscalar=mylib.pricexos;
by Product;
id date interval=month start='01jan1998'd end='01dec2002'd;
var Sale / accumulate=total;
var Price / accumulate=avg;
outarray relsale relprice;
outscalar sbase pbase;
sbase=Sale[1];
pbase=Price[1];
do i=1 to _length_;
if Sale[i] ne . then do;
relsale[i] = Sale[i]/sbase;
end;
if Price[i] ne . then do;
relprice[i]=Price[i]/pbase;
end;
end;
run;
When you convert the preceding statements to use PROC TSMODEL with a CAS table, the code looks like this:
proc tsmodel data=mycas.pricex
outsum=mycas.pricexsum
outarray=mycas.pricexoa
outscalar=mycas.pricexos;
by Product;
id date interval=month start='01jan1998'd end='01dec2002'd;
var Sale /accumulate=total;
var Price /accumulate=avg;
outarray relsale relprice;
outscalar sbase pbase;
submit;
sbase=Sale[1];
pbase=Price[1];
do i=1 to _length_;
if Sale[i] ne . then do;
relsale[i] = Sale[i]/sbase;
end;
if Price[i] ne . then do;
relprice[i]=Price[i]/pbase;
end;
end;
endsubmit;
quit;
Examine these two examples closely to see the differences. At first glance, the differences might not be very obvious. Although the differences in code syntax are subtle, the underlying differences in the procedure processing are profound.
One important difference between PROC TIMEDATA and PROC TSMODEL is that PROC TSMODEL requires you to use the SUBMIT and ENDSUBMIT statements to begin and end the set of programming statements that you want to execute on the time series BY groups. You can include SAS macro statements in the statements in your SUBMIT/ENDSUBMIT block. Table 1 shows the differences between the processing of programming statements in PROC TSMODEL compared to PROC TIMEDATA.
Table 1: Comparison of PROC TSMODEL and PROC TIMEDATA
| Processing Step | PROC TSMODEL | PROC TIMEDATA |
|---|---|---|
| Statement parsing | Any parse-time errors are reported only after the ENDSUBMIT statement. Those errors come from the parsing and compilation of your code in your CAS session. SAS line numbers for incorrect statements are not reported in the SAS log. | Statements are parsed as the procedure works its way through its statement block. Any parse-time errors are interspersed with the program statements in the SAS log. |
| PROC FCMP subroutines and functions | Does not support as many built-in PROC FCMP functions and subroutines. | Supports built-in PROC FCMP functions and subroutines. |
| RUN_MACRO | Not supported because it cannot be performed by the CAS server when it executes your program statements in the context of your CAS session. | Can call the PROC FCMP subroutine RUN_MACRO to run a SAS macro, which can then call a SAS procedure. |
| ID statement with a SAS date or datetime variable | An ID variable is required because the value of the ID variable is needed to determine the time index of each row within the BY group. The accumulation frequency that you specify in the INTERVAL= option in the ID statement is required. | An ID statement is not required. |
| Custom intervals | Custom intervals are not supported at this time. | Custom intervals are supported. |
| Accumulation modes | ACCUMULATE=NONE, FIRST, LAST, NOBS, and MEDIAN are not supported. | ACCUMULATE=NONE, FIRST, LAST, NOBS, and MEDIAN are supported. |
| Output data | Can be printed and plotted through other SAS procedures. | Supports PRINT and PLOT options to display data. |