Help using Base SAS procedures

To find our special characters in sas

Frequent Contributor
Posts: 145

To find our special characters in sas


I am in the process of cleaning  my data…For a variable, is there any function or procedure that will find out special characters or symbols or more then one space in a partilcualr variable. I need to find out if there are any special characters in my dataset.


Super User
Posts: 17,907

Re: To find our special characters in sas

Sometimes its easier to check for what you're looking for.

Ie are the variables all character or numeric?

Look into the ANY<type> of functions - ie anyalpha anydigit anycontrol anypunct

Compress is also a useful function with the appropriate modifiers.

Frequent Contributor
Posts: 145

Re: To find our special characters in sas

I am looking into character variable and we don’t know the type of spcl characters present in the variable but we have filter out if there are any spcl characters in that variable….

Regular Contributor
Posts: 217

Re: To find our special characters in sas

Hi rakeshvvv,

I am aware of many "tricks" to do what you need.  You can scan, index, find, translate a variable to find or remove special characters.  You can remove all numbers and alphas leaving just special characters.  You can compare the length of the original variable to the length of a trimmed, scanned, indexex, found, translated variable.  A variable that is the same length before and after functioning it has no special characters.

I am certain that there are many folks who have routines that they regularly use.  Is there a special style you are comfortable with?  Is there a special set of values you want to check for?   If you trim(left( a variable then translate the remaining spaces to ** you can count the number of ** values in a variable.  If there are more than one * values, then you know you have a variable with two spaces in the middle of the variable.

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation