Your question is also known as
Segmented regression models in SAS
By Rick Wicklin on The DO Loop December 14, 2020
A segmented regression model is a piecewise regression model that has two or more sub-models, each defined on a separate domain for the explanatory variables.
SAS/STAT User's Guide
The MCMC Procedure
Example 80.12 Change Point Models
Do you have many repeated measurements for your patients?
Are the repeated measurements equally spaced and forming a time series?
You could also work with so-called "structural break detection"-methods in time series analysis.
You can detect changing level , changing slope , changing regressor influence , changing variability , changing seasonality , ...
SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation
SAS/ETS 15.3 User's Guide
The UCM Procedure
Example 42.7 Detection of Level Shift
(checkbreak option in LEVEL statement of PROC UCM)
The UCM procedure analyzes and forecasts equally spaced univariate time series data by using an unobserved components model (UCM). The UCMs are also called structural models in the time series literature.
You can make a row number and use interval=day (space between adjacent observations = 1) :
Like here :
data work.class; set sashelp.class; rownum=_N_; run; proc ucm data=work.class; id rownum interval=day; model height; irregular; level plot=smooth checkbreak; estimate; *forecast plot=decomp; run; /* end of program */
Do you have a datetime variable for your measurements?
In that case, and if the (equal) interval in-between measurements is not a typical one (like day, week, 10-days, month, ...), then you can make a custom interval and specify that one in interval= option.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.