Need to get Top 5% of customers data !

Reply
Occasional Contributor
Posts: 12

Need to get Top 5% of customers data !

Hi All,

I need a output dataset with top 5% of transactions from total transaction amount to give promotional offers to the top 5% customers.

Please help !

Super Contributor
Posts: 334

Re: Need to get Top 5% of customers data !

Not sure its clear what you are asking about. Are you wanting the top 5% of customers from the top 5% of transactions? Or do you want the top 5% of customers based on all transactions. And you didnt not mention how to define the "top". Is it total Money, number of items ordered, number of orders, etc... .

What ever the definition is there are many ways to get at what you want. Something like this should help you:

proc sql noprint;

  create table test as

  select make, sum(msrp) as amt format=dollar10.

  from sashelp.cars

  group by make

  order by calculated amt desc

  ;

  select  sum(amt) , round(sum(amt)*.05,1)  into :tamt, :tpct

  from test

  ;

  Create table out as

  select make, amt

  from test

  where amt > &tpct

  ;

quit;

%put &tamt &tpct;

EJ

Super Contributor
Posts: 578

Re: Need to get Top 5% of customers data !

proc sql;

select int(count(*) * .05) as recs

into :Recs

from have;

quit;

proc sql outobs=&recs;

create table offers as

select * from have

order by total_trans_amt desc;

quit;

Ask a Question
Discussion stats
  • 2 replies
  • 343 views
  • 0 likes
  • 3 in conversation