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
Onyx | Level 15

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
Onyx | Level 15

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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