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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.