BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
navyblue
Calcite | Level 5

Hi all,

I have a dataset (see below) that contains interest rate for 1, 2, 3, 5, 7 and 10 year securities. I'd like to interpolate the rates to gather the rates for 4, 6, 8, and 9 years. I looked up the PROC EXPAND procedure but am not quite sure if it's appropriate to use it in my case.

Time Periodtenyrsevenyrfiveyrthreeyrtwoyroneyr
19767.617.427.186.776.315.88
19777.427.236.996.686.456.08
19788.418.368.328.298.338.34
19799.439.479.519.710.1110.65
198011.4311.411.4511.5111.7312
198113.9214.0714.2514.4614.5714.8
198213.0113.0613.0112.9312.812.27
198311.111.0210.7910.4510.219.58
198412.4612.4212.2611.9211.6710.91
198510.6210.510.129.649.278.42
19867.677.547.37.066.866.45

Thank you very much for your suggestions!

Sabrina

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Or better, fit a spline:

data want2;

array ot{10} oneyr twoyr threeyr fouryr fiveyr sixyr sevenyr eithtyr nineyr tenyr;

set have;

do i = 4, 6, 8, 9;

  ot{i} = msplint(i, 6, 1,2,3,5,7,10,oneyr, twoyr, threeyr, fiveyr, sevenyr, tenyr);

  end;

drop i;

run;

PG

PG

View solution in original post

7 REPLIES 7
PGStats
Opal | Level 21

Use the direct approach for linear interpolation:

data have;

input Time_Period tenyr sevenyr fiveyr threeyr twoyr oneyr;

datalines;

1976 7.61 7.42 7.18 6.77 6.31 5.88

1977 7.42 7.23 6.99 6.68 6.45 6.08

1978 8.41 8.36 8.32 8.29 8.33 8.34

1979 9.43 9.47 9.51 9.7 10.11 10.65

1980 11.43 11.4 11.45 11.51 11.73 12

1981 13.92 14.07 14.25 14.46 14.57 14.8

1982 13.01 13.06 13.01 12.93 12.8 12.27

1983 11.1 11.02 10.79 10.45 10.21 9.58

1984 12.46 12.42 12.26 11.92 11.67 10.91

1985 10.62 10.5 10.12 9.64 9.27 8.42

1986 7.67 7.54 7.3 7.06 6.86 6.45

;

data want;

array ot{10} oneyr twoyr threeyr fouryr fiveyr sixyr sevenyr eithtyr nineyr tenyr;

set have;

ot{4} = 0.5 * (ot{3} + ot{5});

ot{6} = 0.5 * (ot{5} + ot{7});

ot{8} = (2*ot{7} + ot{10})/3;

ot{9} = (ot{7} + 2*ot{10})/3;

run;

PG

PG
Reeza
Super User

Can switch the data to a different format (see below) and then run a linear regression if you wanted.

You can use the estimate output to get the interpolated values by including the years you want in the dataset but leave the rate empty.

timeperiod year rate

1976 1 5.88

1976 2 6.31

1976 3 6.77

1976 4 .

navyblue
Calcite | Level 5

Thank you very much Reeza! That was my thought too! I was just curious if there was a more direct way to handle it. Have a great day!

PGStats
Opal | Level 21

Or better, fit a spline:

data want2;

array ot{10} oneyr twoyr threeyr fouryr fiveyr sixyr sevenyr eithtyr nineyr tenyr;

set have;

do i = 4, 6, 8, 9;

  ot{i} = msplint(i, 6, 1,2,3,5,7,10,oneyr, twoyr, threeyr, fiveyr, sevenyr, tenyr);

  end;

drop i;

run;

PG

PG
navyblue
Calcite | Level 5

Yes it works perfectly! Thanks a lot PG! I'll study more about this code and make sure I understand everything about a spline. Have a great day!

Ksharp
Super User

Or you can change it from wide to long, after that using proc expand.

data want2;

array ot{10} oneyr twoyr threeyr fouryr fiveyr sixyr sevenyr eithtyr nineyr tenyr;

set have;

do i =1 to 10;

  vname=vname(ot{i});value=ot{i};output;

  end;

drop i;

run;

Xia Keshan

navyblue
Calcite | Level 5

Yes that's right! Now I can try Proc Expand with it:) Thank you very much and have a nice day!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1561 views
  • 8 likes
  • 4 in conversation