Downloading and Running Code for a Model
You can download the code and data for the model for a selected time seriesan aggregation of transactional data into specified time intervals and sorted according
to unique combinations of the default attributes (BY variables). The downloaded code is CASL and you can run it in SAS Studio to generate the
output tables for the time series.
Note: The example
kubectl commands in the steps below are subject to change.
- Right-click the model and select one of the
following options.
- Download model specification code
-
This option downloads the code for the
specifications of the model. In an ARIMA model, for example, you would see this if
autoregressive (p) is set to 1 and differencing is set to 1.
/* Add the autoregressive (AR) polynomial factor 1. */
array ar_1_1[1]/nosymbols;
ar_1_1[1] = 1;
rc = DIAG1_REGARIMA1.AddARPoly(ar_1_1,,0);
/* Add the differencing. */
array diff_1[1]/nosymbols;
diff_1[1] = 1;
- Download all
-
This option downloads the following
files.
- seriesData.csv – contains the data for the time series, including the time ID (as a numeric SAS date), BY variables, dependent
variable values, and any independent variables used by the model.
- seriesColumnInfo.csv – contains metadata about the time series
- code.casl – contains CASL code to run just this time series.
- specCode.casl – contains the code for the
model specifications that are described above.
- eventData.csv – if one or more custom eventsan incident that disrupts the normal flow of any process that generates the time series.
Examples of events are holidays, retail promotions, and natural disasters. are used in the model, contains the data for the custom events
- eventColumnInfo.csv – if one or more custom events are used in the model, contains metadata about the event table
- Extract the CSV files to a source location from
which you can upload them to the server.
- From the source location, open a Linux shell and
connect to the remote server.
- Enter this command to export the kubeconfig from
the remote server.
export KUBECONFIG=/path/kubeconfig
- Run the following commands to copy the CSV files
from your local drive to the remote server. Repeat these steps to copy eventData.csv
and
eventColumnInfo.csv to the remote server, if needed.
kubectl cp -c cas /SourceLocalPath/seriesData.csv
sas-cas-server-default-controller:cas/data/caslibs/public/seriesData.csv
kubectl cp -c cas /SourceLocalPath/seriesColumnInfo.csv
sas-cas-server-default-controller:cas/data/caslibs/public/seriesColumnInfo.csv
Note that this kubectl command specifies the path
to the CSV files on your local drive, followed by the
sas-cas-server-default-controllerpath/filename.
The caslib is any caslib that you can access. You can rename the CSV files.
- You can verify that the files are copied correctly
by entering the sas-cas-server-default-controller pod, changing to the directory of
the target
caslib, and listing the files in the directory:
kubectl exec sas-cas-server-default-controller -it -- bash
cd cas/data/caslibs/public
ls
- Exit the pod.
exit
- Open SAS Studio. If you already have SAS
Model Studio open, you can click the application menu from the top left and select
Develop SAS Code.
- Start a CAS session to the target caslib. Here is
an example:
cas mycas sessopts=(caslib='public');
libname mylib cas;
- Copy the contents of code.casl into the following
code:
proc cas;
/* insert code.casl contents here */
quit;
- Modify the variables at the top of this code as
needed.
- Change the csvPath variable to point to the
caslib where the CSV files are located. The path should be relative to the caslib
path on the
server. If files are copied to the root of the ‘public’ directory, then the caslib
is
'public' and csvPath must be set to an empty string.
csvPath="";
- If you are using a caslib other than public,
enter the name for that caslib for seriesTableCaslib. Here is an example:
seriesTableCaslib = "temp";
- If you have changed the name of the CSV files,
update the following variables. Here is an example.
seriesTableName = "newSeries";
seriesTableMap = "newMap";
- Specify a prefix for output tables.
outTablePrefix = "newTable.";
- Specify the caslib where output tables should be
generated. The output caslib is set to the input caslib by default.
outTableCaslib = “casuser”;
- Run the CASL code. When the code completes, check
the log to see whether there were any errors. You can also examine the CAS library
for your
session to verify that the tables were created with the prefix that you specified.
The OUTLOG
table also shows any errors generated from the code.
Last updated: March 16, 2026