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!!
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');
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');
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!
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.