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

Hello , 

I have two data tables ( Names LAST_2019 and LAST_2018)  that have the same columns ( DATE  , MATURITY , RATE )

Now I want to combine the two data tables , into one that has the format below :

______________________________________________________

MATURITY_2018  | RATE_2018  | MATURITY 2019 | RATE_2019

1                            |       2.23%      |          1                  |           2.20%

2                            |       2.51%      |          2                 |           2.48%

3                            |       2.78%      |          3                 |          2.62% 

.                             |            .          |            .                |                  . 

.

_______________________________________________________

 

And I want to combine them by maturity ( I mean for every maturity value in 2018 , I have the same value in maturity_2019 with the corresponding RATE_2019.

The DATE column is not important in this last table , so I can disgard it .

Is there any help ? Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

If you are matching based on MATURITY, you need only one MATURITY column in the output.  Here is a way:

 

proc sort data=last_2018;
   by maturity;
run;

proc sort data=last_2019;
   by maturity;
run;

data want;
   merge last_2018 (keep=maturity rate rename=(rate=rate_2018))
      last_2019 (keep=maturity rate rename=(rate=rate_2019));
   by maturity;
run;

View solution in original post

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

First, help us help you. Please post some example data, that resembles your actual data. Makes it a lot easier to provide a usable code answer 🙂

LoPez_Diaz
Obsidian | Level 7

Hello , 

Thank you for your fast reply ; 

The data is presented as follows : 

LAST_2018                                                                                          LAST_2019

 

DATE   |    MATURITY   |   RATE                                                 DATE  |  MATURITY  | RATE 

 D1                  1                    2.25%                                             A1                1                 2.13% 

 D2                  2                    2.38%                                             A2                2                 2.34%

 D3                  3                     2.32%                                            A3                5                 2.16%

 D4                  4                      2.34%                                            .                   .                         . 

.                       .                         .                                                   .                   .                         . 

 

I want to group the two tables to have Something like this : 

 

MATURITY_2018                        RATE_2018                              MATURITY_2019                        RATE_2019

           1                                             2.25%                                              1                                               2.13%

           2                                             2.38%                                               2                                              2.34%

           3                                             2.32%                                               3                                                 - 

           4                                              2.34%                                              4                                              2.16%

 

Thank you ! 

 

Astounding
PROC Star

If you are matching based on MATURITY, you need only one MATURITY column in the output.  Here is a way:

 

proc sort data=last_2018;
   by maturity;
run;

proc sort data=last_2019;
   by maturity;
run;

data want;
   merge last_2018 (keep=maturity rate rename=(rate=rate_2018))
      last_2019 (keep=maturity rate rename=(rate=rate_2019));
   by maturity;
run;
LoPez_Diaz
Obsidian | Level 7

Thank you so much !! this is exactly what I was looking for.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 1036 views
  • 1 like
  • 3 in conversation