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

%let type=Gold;
title "&type Customers";
proc sql number;
select Name, Age_Group, Type
from mc1.customers
where Type contains "&type";
quit;
title;

 

%macro customers(type);
title "&type Customers";
proc sql number;
select Name, Age_Group, Type
from mc1.customers
where type="%upcase(&type)";
quit;
title;
%mend customers;


%customers(Gold)

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

In the first program you are generating this WHERE clause:

where Type contains "Gold"

In the second one you generate this WHERE clause instead:

where type = "GOLD"

So you should see different results.  The only value that satisfies the second test is GOLD which does not contain any lowercase letters and so could not contatin Gold.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

In the first program you are generating this WHERE clause:

where Type contains "Gold"

In the second one you generate this WHERE clause instead:

where type = "GOLD"

So you should see different results.  The only value that satisfies the second test is GOLD which does not contain any lowercase letters and so could not contatin Gold.

A_Kh
Barite | Level 11

It's most likely uppercase is used in the macro definition (where type="%upcase(&type)"). 
Check your data, look at your first sql step that works with %let statement.  
Try this: 

%macro customers(type);
title "&type Customers";
proc sql number;
select Name, Age_Group, Type
from mc1.customers
where type="&type";
quit;
title;
%mend customers;


%customers(Gold);



hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2 replies
  • 609 views
  • 1 like
  • 3 in conversation