DATA Step, Macro, Functions and more

making a macro variable/parameter all uppercase

Posts: 0

making a macro variable/parameter all uppercase

I have recently been fairly frustrated by SAS's insistence on using string functions only on dataset variables, and not macro variables.

I just wrote a macro that has a parameter which allows the user to name a set of variables to be excluded from the macro's analysis:


This parameter is called later in an sql where clause:

proc sql;
create table noequal&name as
select * from noequal&name.1
where Variable_Name not in &droplist;

This works fine, but I would like to change the program so that this comparison is not case sensitive. Unfortunately, SAS does not allow me to use upcase() on a macro variable, and my attempts to force the variable into a dataset have been unsuccessful due to its required punctuation and length.

Does anyone know how to possibly fix this problem?
Posts: 8,743

Re: making a macro variable/parameter all uppercase

Valued Guide
Posts: 2,175

Re: making a macro variable/parameter all uppercase

in addition to the (always) sensible suggestions from Cynthia,
you can also invoke the base SAS function COMPARE() within %sysfunc().
The benefit of compare() is that it has a parameters to indicate options like:
1 you wish it to be case insensitive,
2 ignore leading blanks
3 compare over the length of the shorter of the two strings, rather than the default longer
4 remove quotes from name-literals

and it will return the position within the strings of the first difference.

a better description than mine can be found in the documentation on the SAS web site at .

so be frustrated more by our difficulty in finding appropriate search terms to find the solution to our problem - often our expectations are wrong because more issues than we anticipate have frustrated a simple search.

good luck
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation