BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Saraja
Fluorite | Level 6

 

Hi,

I am new to Proc Sql and wondering how to use wild cards such as 'SAS%' (SAS*) or 'SAS____ to identify the library names with SAS as prefix in the following code. Same is treu for the MAPS libraries as prefix or SAS as suffix.

Can someone explain these wild cards by showing side by side how they are different from data step.

Appreciated!

 

data metadata2;
    set sashelp.vcolumn;
    where libname not in ('SASHELP', "SASHELP",  'SASUSER', 'SAMPSIO',
    'SUBFUNC', 'MAPS', 'MAPSSAS', 'MAPSGFK', 'SAL428SL', 'STP:', 'TLV4');
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Your use of colon in your initial example wouldn't have worked anyway. Here is a simplified version which, as you can see if you test it, doesn't work:

 

data metadata2;
    set sashelp.vcolumn;
    where libname in ('SAS:');
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

The same syntax can be used with both. e.g.:

data metadata2;
    set sashelp.vcolumn;
    where libname not like ('SAS%') and
          libname not like ('STP%') and
          libname not like ('MAPS%') and
          libname not in ('SAMPSIO','SUBFUNC', 'SAL428SL', 'TLV4');
run;

proc sql;
  create table metadata2 as
    select *
      from dictionary.columns
        where libname not like ('SAS%') and
              libname not like ('STP%') and
              libname not like ('MAPS%') and
              libname not in ('SAMPSIO','SUBFUNC', 'SAL428SL', 'TLV4')
  ;
quit;

Art, CEO, AnalystFinder.com

 

Saraja
Fluorite | Level 6
Thank you very much Art, this code is very elegant.
I was hoping to put the wild card terms into the one list as in the last
line but looks like that its not possible.
Again, thanks !
art297
Opal | Level 21

Your use of colon in your initial example wouldn't have worked anyway. Here is a simplified version which, as you can see if you test it, doesn't work:

 

data metadata2;
    set sashelp.vcolumn;
    where libname in ('SAS:');
run;

Art, CEO, AnalystFinder.com

 

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
  • 1161 views
  • 1 like
  • 2 in conversation