BookmarkSubscribeRSS Feed
srdr1217
Calcite | Level 5
Acc_NoTransaction_DateTransaction_Amount
1001-Jul-151000
1002-Jul-152000
1003-Jul-153000
1004-Jul-154000
1005-Jul-155000
1016-Jul-156000
1017-Jul-157000
1018-Jul-152500
1019-Jul-15500
4 REPLIES 4
AskoLötjönen
Quartz | Level 8

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;

Loko
Barite | Level 11

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;

KrisNori
Obsidian | Level 7

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;

ChrisNZ
Tourmaline | Level 20

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1607 views
  • 0 likes
  • 5 in conversation