SAS Cloud Time Series Processing


SAS Cloud Time Series Processing

Anna
Have you heard about SAS Visual Forecasting's new External Languages Package? It lets you use Python and R code alongside SAS for time series processing.

Hope
I've heard a bit about that. But how does the back-end actually work? They mentioned something called TSMODEL.

Anna
Right. TSMODEL is a cloud-based infrastructure that runs on top of Cloud Analytic Services. It handles data movement and processing across a cluster, and it scales really well—they've tested it with millions of time series.

Hope
So what happens when you submit a script? Does it just run on each node?

Anna
Yes. The system replicates your script—which can now mix SAS, Python, and R—onto each worker node. That script gets compiled into machine code for efficiency. Then, when you have Python or R code, the node launches an interpreter, like python.exe, and feeds it the extracted code.

Hope
What about data? How does the parallel processing work?

Anna
The distributed file system sends the data to the nodes automatically. For example, if you have seven time series across two tables and four nodes, three nodes get two series each and the last gets one. With modern nodes having multiple CPU cores, they can process all series in parallel. The output goes back to the file system automatically.

Hope
I imagine sharing data between SAS and Python could be tricky. How is that handled?

Anna
They make it easy with shared variables. You specify which variables to pass using the AddVariable method. You can also set an alias so your existing Python code doesn't need to change. And to avoid unnecessary data movement, you can mark variables as read-only—only those you want to write back are sent.

Hope
The External Languages Package seems to have different object types. Can you break those down?

Anna
Sure. There are interpreter objects—like Python2 or R—that let you insert code directly, from a file, or from a CAS table. Then collector objects store logs or shared variable status into CAS tables so you can troubleshoot later. And there's a repeater object for loading stored source code.

Hope
Interesting. Can you walk me through an actual example? Something like a moving average calculation?

Anna
Absolutely. First, you set up PROC TSMODEL with your input data, like a skin product sales table. You specify the time variable, the BY variable for parallelization (like distribution center), and the revenue variable you want to analyze. Then you require the External Languages Package, start a submit block, and create a Python interpreter object.

Hope
Got it. Then you need to share variables, right?

Anna
Exactly. You use AddVariable for revenue (read-only) and for the moving average you want to compute (not read-only so it's written back). Then you insert your Python code—using convolution to compute the moving average—call the run method, and collect the logs with an OUTEXTLOG object. That's it; the heavy lifting is just that little bit of setup.

Hope
What about using this through the GUI? Can you integrate external language code into Model Studio?

Anna
Yes, you can add open source nodes to pipelines in Model Studio. For instance, you can include an R ARIMA model as part of automatic model selection. The system then uses that code alongside traditional SAS models.

Hope
That's really powerful. It opens up time series processing to a much wider range of analysts.

Anna
And it scales incredibly well. They showed a benchmark: processing 87 GB of data with 400 threads took about 5 minutes, compared to 130 hours with serial processing. So it's both flexible and performant.

Ask anything
We've read this whole study set, so questions about it get the best answers.