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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: