Help using Base SAS procedures

piecewise manipulation of time-series data

Occasional Contributor
Posts: 8

piecewise manipulation of time-series data


I am not new to programming but I am new to SAS. I am having some trouble understanding how to perform multistep data processing in SAS. At this point, I'm not even sure if it's possible to do what I want to do in SAS.


Time     Value

1          300

2          320

3          350

4          280

5          300


I have a data matrix that has about 300 entries, where the time increments by 1 and the value fluctuates somewhat randomly with time, as above.

I want to set an N-value, let's say N=10, and perform piecewise linear regressions for every N time points. I then want to subtract the linear regression values from the Value column (detrending the data - piecewise). There are some examples of piecewise linear regressions online, but they are all exclusive to two pieces. I've tried using an additional column to deliminate the pieces, but SAS doesn't perform matrix operations the way I am used to.

I also want to calculate a root-mean-square value for each N time-piece.

Lastly, I want to repeat this for many values of N.

At this point, I can perform the individual actions (linear regression, root-mean-square), but am having trouble cycling through piecewise. I also am having trouble performing calculations on the Values using the results from my regressions.

I would appreciate some help on how to cycle through piecewise regressions.



Respected Advisor
Posts: 4,647

piecewise manipulation of time-series data

Look at PROC LOESS. I think it does all that you want to do and a lot more...


Occasional Contributor
Posts: 8

piecewise manipulation of time-series data

Thanks, I've looked through the documentation and that was supremely helpful to what I was trying to do.


Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation