BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mrahouma
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

3 REPLIES 3
yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



mrahouma
Obsidian | Level 7
Thanks a lot. Greatly appreciated
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1046 views
  • 2 likes
  • 3 in conversation