Help using Base SAS procedures

Count of repititve amount by month and account number

Reply
Occasional Contributor LOK
Occasional Contributor
Posts: 11

Count of repititve amount by month and account number

Hi,

Base dataset

month a/cno amount
jan 1001 100
jan 1001 200
jan 1001 100
jan 1001 100
jan 1001 200
jan 1001 500
jan 1002 500
jan 1002 500


i require output dataset like this

month a/cno amount count
jan 1001 100 1
jan 1001 100 2
jan 1001 100 3
jan 1001 200 1
jan 1001 200 2
jan 1001 500 1
jan 1002 500 1
jan 1002 500 2

Require count for repetitive amount...by month and a/c no
provide me the code... Message was edited by: NIKKI
N/A
Posts: 0

Re: Count of repititve amount by month and account number

Hi Nikki,


plz try the following code.


data sample;
input month $ acno amount;
datalines;
jan 1001 100
jan 1001 200
jan 1001 100
jan 1001 100
jan 1001 200
jan 1001 500
jan 1002 500
jan 1002 500
;
proc sort data=sample;
by month acno amount;
run;
data sample1;
set sample;
retain cnt;
by month acno amount;
if first.amount then cnt=1;
else cnt+1;
run;

Thanks
Slone
Occasional Contributor LOK
Occasional Contributor
Posts: 11

Re: Count of repititve amount by month and account number

Hi, Slone
Thankyou!
Ask a Question
Discussion stats
  • 2 replies
  • 95 views
  • 0 likes
  • 2 in conversation