## Regression with restricted cubic splines

Solved
Occasional Contributor
Posts: 7

# Regression with restricted cubic splines

Hi all,

I want to graph the spline functions, so I create a data set to store spline basis functions, and I got the data set that is below. The issue is when I want to call the spl1-spl4 variables (In the data set appear like spl 1 spl 2 spl 3 and spl 4). The program doesn't recognize any form to call them (nor spl 1 spl 2 spl 3 spl4 neither spl_1 spl_2 spl_3 spl_4).  Can anyone help me?

``````/* Create SplineBasis = data set that contains spline basis functions */
effect spl = spline(lactationbypar / naturalcubic basis=tpf(noint) knotmethod=percentiles(5));
model weightchange2 = spl / selection=none;
quit;

proc sgplot data=SplineBasis;
series x=lactationbypar y=spl1;
series x=lactationbypar y=spl2;
series x=lactationbypar y=spl3;
series x=lactationbypar y=spl4;
run;

``````

Thanks,

Accepted Solutions
Solution
‎07-26-2017 11:42 PM
Super User
Posts: 22,026

## Re: Regression with restricted cubic splines

[ Edited ]

Run a proc contents and verify the variable name and label. You need the name. If the name happens to have spaces, then wrap it in qutoes and add an N at the end.

``'SP 1'n``

mmazariegos wrote:

Hi all,

I want to graph the spline functions, so I create a data set to store spline basis functions, and I got the data set that is below. The issue is when I want to call the spl1-spl4 variables (In the data set appear like spl 1 spl 2 spl 3 and spl 4). The program doesn't recognize any form to call them (nor spl 1 spl 2 spl 3 spl4 neither spl_1 spl_2 spl_3 spl_4).  Can anyone help me?

``````/* Create SplineBasis = data set that contains spline basis functions */
effect spl = spline(lactationbypar / naturalcubic basis=tpf(noint) knotmethod=percentiles(5));
model weightchange2 = spl / selection=none;
quit;

proc sgplot data=SplineBasis;
series x=lactationbypar y=spl1;
series x=lactationbypar y=spl2;
series x=lactationbypar y=spl3;
series x=lactationbypar y=spl4;
run;

``````

Thanks,

All Replies
Solution
‎07-26-2017 11:42 PM
Super User
Posts: 22,026

## Re: Regression with restricted cubic splines

[ Edited ]

Run a proc contents and verify the variable name and label. You need the name. If the name happens to have spaces, then wrap it in qutoes and add an N at the end.

``'SP 1'n``

mmazariegos wrote:

Hi all,

I want to graph the spline functions, so I create a data set to store spline basis functions, and I got the data set that is below. The issue is when I want to call the spl1-spl4 variables (In the data set appear like spl 1 spl 2 spl 3 and spl 4). The program doesn't recognize any form to call them (nor spl 1 spl 2 spl 3 spl4 neither spl_1 spl_2 spl_3 spl_4).  Can anyone help me?

``````/* Create SplineBasis = data set that contains spline basis functions */
effect spl = spline(lactationbypar / naturalcubic basis=tpf(noint) knotmethod=percentiles(5));
model weightchange2 = spl / selection=none;
quit;

proc sgplot data=SplineBasis;
series x=lactationbypar y=spl1;
series x=lactationbypar y=spl2;
series x=lactationbypar y=spl3;
series x=lactationbypar y=spl4;
run;

``````

Thanks,

Occasional Contributor
Posts: 7

## Re: Regression with restricted cubic splines

Thank you very much Reeza, It works!

``'spl 1'n``

☑ This topic is solved.