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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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