BookmarkSubscribeRSS Feed
OS2Rules
Obsidian | Level 7

Hi All:

A quick question about how to code an SQL:

I have a prefix value (a data set name) in one table, and a fully qualified name (including the member name and extension) in a second table.

Is there a way to code a SQL to match these?  I thought to use something like:

where a.prefix =: b.dsn

but this will not work.

I am not concerned whether the fully qualified name contains multiple sub directories, as long as the prefix matches.

Thanks in advance.

3 REPLIES 3
LarryWorley
Fluorite | Level 6

Try like operator with multi-character wild card "%'

where b.dsn like trim(a.prefix)||'%'

Haikuo
Onyx | Level 15

colon operator is not working in Proc SQL, you probably need to use scan():

where a.prefix=scan(b.dsn,1)

Haikuo

Astounding
PROC Star

I suspect LarryWorley hit the nail on the head, but just in case this should be worth a shot:

where trim(a.prefix) = substr(b.dsn, 1, length(a.prefix))

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