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');
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.