0

I have a dataset as follows:

data have;
input;

        ID    Base    Adverse    Fixed$    Date    RepricingFrequency
        1     38      50         FIXED     2016    2
        2     40      60         FLOATING  2017    3
        3     20      20         FIXED     2016    2
        4     ...
        5
        6

I am looking to build an array such that each ID has four vintage years 2017-2020, where the subsequent years are to be filled out with a piece of array code I have that works

like such

    ID Vintage   Base    Adverse    Fixed$    Date    RepricingFrequency
    1  2017      38      50         FIXED     2016    2
    1  2018                                       
    1  2019                                       
    1  2020                                   

In the beginning I just need to duplicate the dataset with the blanks,

The code I've tried so far is

data want;
set have;
do I=1 to 4;
output;
drop I;
run;

but of course that keeps the repeats of all the observations. So I tried an array.

data want;
set have;

array Base(2017:2020) Base2017-Base2020
array Vintage(2017:2020) Vintage2017-Vintage2020

But I'm not sure where to go from here on either accord.

The question is how do I extrapolate my data set for ID1-8 to a dataset where I have ID 1111-8888 where each ID is repeated 4 times with blanks.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
78282219
  • 593
  • 5
  • 21

1 Answers1

1

Make a dummy dataset with all of the observations

data frame ;
  set have(keep=id);
  by id ;
  if first.id then do date=2017 to 2020 ;
    output;
  end;
run;

and merge it back with the original.

data want ;
  merge have frame ;
  by id date ;
run;
Tom
  • 47,574
  • 2
  • 16
  • 29