-1

I have a data set like this:

AcntNum  name  date
100      abc   12/01
         abc2  12/02
         abc3  12/03
101      abc4  12/04
         abc5  12/05
         abc6  12/06

I am trying to accomplish the below result dataset: Result:

AcntNum  name  date
100      abc   12/01
100      abc2  12/02
100      abc3  12/03
101      abc4  12/04
101      abc5  12/05
101      abc6  12/06

Please suggest what method to follow.

Thanks,

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user2800204
  • 15
  • 1
  • 6

2 Answers2

2

You need to use RETAIN and another variable. Here is one way.

data want;
  set have;
  retain acntnum2;
  acntnum=coalesce(acntnum,acntnum2);
  acntnum2=acntnum;
run;
Tom
  • 47,574
  • 2
  • 16
  • 29
0

there's probably a better way but you could try the following:

data raw1;                                                                                                                              
set raw ;                                                                                                                               
retain group;                                                                                                                           
if( _n_ = 1) then group = 0;                                                                                                            
if (acct ne .) then group = group +1;                                                                                                   
run;                                                                                                                                    



data raw2;                                                                                                                              
set raw1;                                                                                                                               
retain acct2;                                                                                                                           
by group;                                                                                                                               
if first.group then acct2 = acct;                                                                                                       
run; 
DCR
  • 14,737
  • 12
  • 52
  • 115