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
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: