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 ;
       

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1200 views
  • 0 likes
  • 2 in conversation