Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to build a sting for Proc SQL

Status
Not open for further replies.

dbdinc

MIS
Apr 13, 2007
58
US
I've got a parameter in a stored process that can have multiple selections, and code that Cynthia suggested is works for building the parameters I then use in subsequent Proc SQL processing. The code is as follows (and yes it's in a sotred process):

%let campuscodescls = "%superq(campuscodes)";
%local i;
%if %superq(campuscodes0) ne
%then %do i=2 %to %superq(campuscodes0);
%let campuscodescls = &campuscodescls,"%superq(campuscodes&i)";
%end;

Here's my question: how can I modify that type of code to instead of picking an entire piece of data in a field, to perform LIKE checking ("If FIELDA LIKE *widget* OR FIELDA LIKE *wadget* or FIELDA LIKE *whatsis* " ?) I can't change my parameter criteria to do this, because the same parameter criteria are also used in other processing.

Thaks to all who answer...looking forward to your replies......
 
I think what you want is the %INDEX macro function. This returns the byte number of the first letter of the matched string.
Check this for full details.

So you would write your "If FIELDA LIKE *widget*" as
Code:
  %if %index(&FIELDA,"*widget*") > 0 % then...


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Chris,

This is dbdinc. I had to create a new id because something happened to my old id and I haven't been able to log in using dbdinc. I sent notes to the forum managers three times but got absolutely no response. Anyway, that's why the new id.

Just wanted to say thanks for your response....didn't want you thinking I was either rude or ignoring you. I appreciate your taking the time to help out others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top