I have the following dataset
data orders;
input customerid OrderDate DATE7. Model $13-24 Quantity;
cards;
287 15OCT03 Dealr Breeze 15
287 15OCT03 Sarah Ana 15
274 16OCT03 Gee Stream 1
174 17OCT03 Sarah Ana 20
174 17OCT03 Nor'easter 5
174 17OCT03 Scirocco 1
347 18OCT03 Mistral 1
287 21OCT03 Dealr Breeze 30
287 21OCT03 Gee Ana 25
;
run;
I want to write a macro called pick_order that will print a subset of the data set orders
for a selected customer---> So I wrote the following code;
%macro pick_order (id=);
proc print data=Orders noobs;
where customerid = "&id.";
title "&id. Orders";
run;
%mend pick_order;
*THEN I want to run my macro I have written to print the table for customer 287;
%pick_order (id=287);
I got the following error:
ERROR: WHERE clause operator requires compatible variables.
Any advie will be greatly appreciated.
Hi,
your customerId is numeric, and in the WHERE you are using "&id." which is character
Make it:
where customerid = &id.;
All the best
Bart
Hi,
your customerId is numeric, and in the WHERE you are using "&id." which is character
Make it:
where customerid = &id.;
All the best
Bart
OTOH, it would be better to store the customer ID as character. You'll never do calculations with it.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.