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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 555 views
  • 0 likes
  • 2 in conversation