Dear all,

I am working with string data and I would like to identify observations that have special characters ("/" "?" "*" "(" "." ")" and others), numbers and whitespace (except leading and trailing spaces) in a string variable.

The dataset is like
string_var
E.V.A
F7010P
175/70R14
C B U Q
*E.D.T.A
(S6X60D)
COLA

In particular, I would like the dataset to be as the following
string_var has_special_char
E.V.A 1
F7010P 1
175/70R14 1
C B U Q 1
*E.D.T.A 1
(S6X60D) 1
COLA 0
where 'has_special_char' is a dummy for whether the observation has special characters, numbers or whitespace (except leading and trailing spaces) in the variable 'string_var'.

Could you help me to find a solution for that?

Thank you very much!

Below I provide the code for importing the example dataset into Stata:

clear
input str10 string_var
"E.V.A"
"F7010P"
"175/70R14"
"C B U Q"
"*E.D.T.A"
"(S6X60D)"
"COLA"
end