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

Hi,

I want to check if all my variable names in my data set contains nothing other than alphabetic letters, numbers, or underscore. I've tried 

select * from dictionary.columns where libname = mylib

and memname  = mydata and name not like "%[0-9][A-Z][_]%";

So ideally if there exists a variable name that has a special letter, proc sql step will return that variable name. But I don't think I'm using the wildcard operation correctly.

Please help!!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Example using the FINDC function

 


data want;
       input word $16.;
       invalid_char_position=findc(trim(word),'abcdefghijklmnopqrstuvwxyz_','idk');
cards;
abc_def
abC_Def7_e
7eiw
_6^78
;

 Or, slightly less typing

 

    invalid_char_position=findc(trim(word),'','nk');
--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

Example using the FINDC function

 


data want;
       input word $16.;
       invalid_char_position=findc(trim(word),'abcdefghijklmnopqrstuvwxyz_','idk');
cards;
abc_def
abC_Def7_e
7eiw
_6^78
;

 Or, slightly less typing

 

    invalid_char_position=findc(trim(word),'','nk');
--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 525 views
  • 0 likes
  • 2 in conversation