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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.