BookmarkSubscribeRSS Feed
AmirSari
Quartz | Level 8

Hi all,

 

I am trying to add US treasury yield to my dataset based on issue and maturity dates. For observations without exact matches I want to use linear interpolation. Matching the observation with the same issue and maturity dates is easy, but using linear interpolation for those that don't have a exact maturity match is what I am having trouble with. Here is samples of my dataset. I have also attached the US treasury yield dataset.

 

MySample:

Issuedate     MaturityDate     ticker

1/11/1990    1/15/1994           EK

1/18/1990    1/15/1996           CO

3/07/1990    3/15/2002           DP

 

 

There are multiple observations in the treasury file that have the same issue date but different maturity dates. To do linear interpolation, for any observation in my data, I need the two closest observations on maturity dates in the treasury file so that I could use proc expand and linear interpolate. If I could get something like this, then I can use proc expand and do linear interpolation.

 

Issuedate     MaturityDate    ticker          Issue              Maturity              Yield

1/11/1990    1/15/1994           EK        1/11/1990          1/11/1993            7.95

1/11/1990    1/15/1994           EK        1/11/1990          1/11/1994               .

1/11/1990    1/15/1994           EK        1/11/1990          1/11/1995            7.94

1/18/1990    1/15/1996           CO       1/18/1990          1/18/1995            8.27

1/18/1990    1/15/1996           CO       1/18/1990          1/18/1996               .

1/18/1990    1/15/1996           CO       1/18/1990          1/18/1997            8.31

3/07/1990    3/15/2002           DP       3/07/1990          3/07/2000            8.58

3/07/1990    3/15/2002           DP       3/07/1990          3/07/2002               .

3/07/1990    3/15/2002           DP       3/07/1990          3/07/2010               .

 

 

 

Any help is much appreciated

1 REPLY 1
johnsville
Obsidian | Level 7

data samples ;
infile datalines ;
input
    issuedate :mmddyy10.
    maturitydate :mmddyy10.
    ticker :$2.
;
format issuedate maturitydate mmddyys10. ;
datalines;
1/11/1990    1/15/1994           EK
1/18/1990    1/15/1996           CO
3/07/1990    3/15/2002           DP
;

libname UST "/folders/myfolders/data/treasuries" ;

proc sql noprint ;
    create table two as
    select s.issuedate
        , s.maturitydate
        , s.ticker
        , t.issue
        , t.maturity
        , t.yield
    FROM samples s
    JOIN UST.treasury t
    on s.issuedate eq t.issue
    and s.maturitydate le t.maturity
    ;
quit ;
       

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 748 views
  • 0 likes
  • 2 in conversation