BookmarkSubscribeRSS Feed
ManoharNath
Obsidian | Level 7

Hi All,

Please solve this query. Suppose there are two variable ( Account number , Transaction Amount )  and

I want 3rd Transaction_Amount of each account number. Can you please solve this.

Regards,

Manohar

Account_number, Transaction_Amount

10001     250000

10001     256699

10001     155665

10001     789562

20001     985466

20001     856956

20001     155464

20001     145889

2 REPLIES 2
naveen_srini
Quartz | Level 8

Hi,

Let me if this works for you

data inp;

input Account_number $ Transaction_Amount;

datalines;

10001 250000

10001 256699

10001     155665

10001     789562

20001     985466

20001     856956

20001     155464

20001     145889

;

data outp(drop=count);

set inp;

by account_number notsorted;

if first.account_number then count=0;

count+1;

if count=3 then output;

run;

Thanks

Naveen Srinivasan

L&T infotech

FriedEgg
SAS Employee

data have;

input account_number transaction_amount @@;

cards4;

10001 250000 10001 256699 10001 155665 10001 789562

20001 985466 20001 856956 20001 155464 20001 145889

;;;;

/*if you want in order with transaction_amount add a sort

proc sort;

by account_number transaction_amount;

*/

data want;

do _n_=1 by 1 until (last.account_number);

   set have;

   by account_number;

   if _n_=3 then output;

end;

run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 1106 views
  • 4 likes
  • 3 in conversation