This question is from SAS Macro Language 1;
Question :
Reminder: Make sure you've defined the Orion library.
title; footnote; %macro tops(obs=3); proc means data=orion.order_fact sum nway noprint; var total_retail_price; class customer_ID; output out=customer_freq sum=sum; run; proc sort data=customer_freq; by descending sum; run; data _null_; set customer_freq(obs=&obs); call symputx('top'||left(_n_), Customer_ID); run; %mend tops;
my code:
title;
footnote;
%macro tops( obs=3);
proc means data=orion.order_fact sum nway noprint;
var total_retail_price;
class customer_ID;
output out=customer_freq sum=sum;
run;
proc sort data=customer_freq;
by descending sum;
run;
data _null_;
set customer_freq(obs=&obs) ;
call symputx('top'||left(_n_), Customer_ID);
run;
%do i = 1 %to &obs ;
proc print data = orion.customer_dim;
where Customer_ID = &&top&i ;
run;
%end ;
%macro tops( obs=3);
proc means data=orion.order_fact sum nway noprint;
var total_retail_price;
class customer_ID;
output out=customer_freq sum=sum;
run;
proc sort data=customer_freq;
by descending sum;
run;
data _null_;
set customer_freq(obs=&obs) ;
call symputx('top'||left(_n_), Customer_ID);
run;
%do i = 1 %to &obs ;
proc print data = orion.customer_dim;
where Customer_ID = &&top&i ;
run;
%end ;
%mend tops;
%tops();
My output is in a different format. Can someone help me to get the output in this format.
Top 3 Customers |
10 | Karen Ballinger | Orion Club members high activity |
16 | Ulrich Heyde | Internet/Catalog Customers |
45 | Dianne Patchin | Orion Club Gold members low activity |
Hi:
The exercises in the e-learning classes have the solution provided to you. Just click the Show Solution button at the bottom of the screen and you should see the solution inside the code that is showing on a blue background, as shown below.
cynthia
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.
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.