BookmarkSubscribeRSS Feed
rakeshvvv
Quartz | Level 8

Hi,

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.

Thanks

3 REPLIES 3
Reeza
Super User

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.

rakeshvvv
Quartz | Level 8

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….

jwillis
Quartz | Level 8

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 3019 views
  • 0 likes
  • 3 in conversation