BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
2 REPLIES 2
Peter_C
Rhodochrosite | Level 12
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 3406 views
  • 0 likes
  • 3 in conversation