DATA Step, Macro, Functions and more

making a macro variable/parameter all uppercase

Reply
N/A
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:

droplist=("age1y1_S","age1y2_S","age1y3_S","age2y1_S","age2y2_S","age2y3_S")

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?
SAS Super FREQ
Posts: 8,864

Re: making a macro variable/parameter all uppercase

Posted in reply to deleted_user
Valued Guide
Posts: 2,177

Re: making a macro variable/parameter all uppercase

Posted in reply to deleted_user
Zantan
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 http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#/documentation/cdl/... .


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
peterC
Ask a Question
Discussion stats
  • 2 replies
  • 469 views
  • 0 likes
  • 3 in conversation