DATA Step, Macro, Functions and more

Wild Cards used in Proc SQl are different that those used in Data Step.

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Wild Cards used in Proc SQl are different that those used in Data Step.

[ Edited ]

 

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;

 


Accepted Solutions
Solution
‎06-18-2018 10:46 PM
Super User
Posts: 8,214

Re: Wild Cards used in Proc SQl are different that those used in Data Step.

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


All Replies
Super User
Posts: 8,214

Re: Wild Cards used in Proc SQl are different that those used in Data Step.

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

 

New Contributor
Posts: 4

Re: Wild Cards used in Proc SQl are different that those used in Data Step.

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 !
Solution
‎06-18-2018 10:46 PM
Super User
Posts: 8,214

Re: Wild Cards used in Proc SQl are different that those used in Data Step.

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

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 112 views
  • 0 likes
  • 2 in conversation