It's always difficult to match results from different software because each software uses different defaults. For splines, there is the question of how to place the internal and external (boundary) knots. Also, be aware that SAS and R use different defaults for quantiles.
In SAS, you can use the EFFECT statement in many regression procedures to use a B-spline basis. You can output the spline basis, but that is usually not necessary. For linear models, use PROC GLMSELECT with the SELECTION=NONE option on the model statement. See the blog posts that KSharp listed, but use the BASIS=BSPLINE option.
In SAS IML, you can use the BSPLINE function to get the basis of B-splines. This is closest to your R code.
data work.cars;
set sashelp.cars(obs=50);
where weight^=.;
keep mpg_city weight;
run;
proc iml;
/* compute the B-spline basis in R */
call exportdatasettoR("work.cars", "cars");
submit/R;
library(splines)
cars
wt_25 <- quantile(cars$Weight, 0.25)
wt_75 <- quantile(cars$Weight, 0.75)
wt_25
wt_75
age_spline <- bs(cars$Weight, knots = c(wt_25, wt_75), degree = 3)
age_spline # generate degree 3 (cubic) B-splines with 2 internal knots
attr(age_spline,"knots")
attr(age_spline,"Boundary.knots")
endsubmit;
/* compute it in IML by using BSPLINE function */
use cars;
read all var "weight";
close;
q = {3351.5 , 3925.25 };
deg = 3;
knots = repeat(min(weight), deg) /* use deg boundary knots */
// q //
repeat(max(weight), deg);
print knots;
wt_spline = bspline(weight, deg, knots);
/* the R bs() function does not include the first column */
wt_spline = wt_spline[,2:ncol(wt_spline)];
create bspline from wt_spline;
append from wt_spline;
close;
QUIT;
If you want to perform regression, use PROC GLMSELECT or another regression procedure.
... View more