Acc_No | Transaction_Date | Transaction_Amount |
100 | 1-Jul-15 | 1000 |
100 | 2-Jul-15 | 2000 |
100 | 3-Jul-15 | 3000 |
100 | 4-Jul-15 | 4000 |
100 | 5-Jul-15 | 5000 |
101 | 6-Jul-15 | 6000 |
101 | 7-Jul-15 | 7000 |
101 | 8-Jul-15 | 2500 |
101 | 9-Jul-15 | 500 |
proc sort data=have;
by Acc_No Transaction_Date;
run;
data have;
set have ;
by Acc_No Transaction_Date;
retain order 0;
if first.Acc_no then order = 0;
order+1;
run;
data want;
set have;
if order = 2;
run;
Hello,
data have;
input Acc_No Transaction_Date date8. Transaction_Amount ;
format Transaction_Date date9.;
datalines;
100 1-Jul-15 1000
100 2-Jul-15 2000
100 3-Jul-15 3000
100 4-Jul-15 4000
100 5-Jul-15 5000
101 6-Jul-15 6000
101 7-Jul-15 7000
101 8-Jul-15 2500
101 9-Jul-15 500
;
data want;
set have (keep=Acc_No) ;
by Acc_No;
set have(firstobs=2 drop=Acc_No);
if first.Acc_No;
run;
Data a;
INFILE CARDS;
INPUT Acc_no @;
IF Acc_no = 100;
INPUT Transaction_date:DATE9. Trans_Amt;
DATALINES;
100 1-Jul-15 1000
100 2-Jul-15 2000
100 3-Jul-15 3000
100 4-Jul-15 4000
100 5-Jul-15 5000
101 6-Jul-15 6000
101 7-Jul-15 7000
101 8-Jul-15 2500
101 9-Jul-15 500
;
PROC PRINT DATA = a (FIRSTOBS =2 OBS=2);
FORMAT Transaction_date DATE9.;
RUN;
data have;
input Acc_No Transaction_Date date8. Transaction_Amount ;
format Transaction_Date date9.;
datalines;
100 1-Jul-15 1000
100 2-Jul-15 2000
100 3-Jul-15 3000
100 4-Jul-15 4000
100 5-Jul-15 5000
101 6-Jul-15 6000
101 7-Jul-15 7000
101 8-Jul-15 2500
101 9-Jul-15 500
;
data want;
set have;
by Acc_No;
if lag(first.Acc_No);
putlog Transaction_Date;
run;
02JUL2015
07JUL2015
Add a where clause if you need one customer only.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.