BookmarkSubscribeRSS Feed
SOORISAS
Calcite | Level 5

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 !

2 REPLIES 2
esjackso
Quartz | Level 8

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

DBailey
Lapis Lazuli | Level 10

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;

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