data have1;
input ln $ setup_dt Date9. ;
format setup_dt mmddyy10.;
datalines;
12000 29Jul2019
12000 30Jul2019
12000 30Jul2019
12000 31Jul2019
12500 31Aug2019
15600 1Aug2019
15700 2Aug2019
;run;
data want;
set have1;
by ln ;
if first.ln then group_id+1;
run;
Output
| ln |
setup_dt |
group_id |
| 12000 |
07/29/2019 |
1 |
| 12000 |
07/30/2019 |
1 |
| 12000 |
07/30/2019 |
1 |
| 12000 |
07/31/2019 |
1 |
| 12500 |
08/31/2019 |
2 |
| 15600 |
08/01/2019 |
3 |
| 15700 |
08/02/2019 |
4 |
| |
|
|
| Desired as follows |
| |
|
|
| ln |
setup_dt |
group_id |
| 12000 |
07/29/2019 |
1 |
| 12000 |
07/30/2019 |
2 |
| 12000 |
07/30/2019 |
2 |
| 12000 |
07/31/2019 |
3 |
| 12500 |
08/31/2019 |
1 |
| 15600 |
08/01/2019 |
1 |
| 15700 |
08/02/2019 |
1 |
The desire is that when the same ln shows a new setup_dt, it increments from 1 to 2 or 3 etc depending on the number of dates. It then should reset to 1 when the ln changes