BookmarkSubscribeRSS Feed
geneshackman
Pyrite | Level 9

Hi all

My data set has a column of numbers. Some numbers in the column have *, so for example

1
2​
4*
3
2*
5*
2

How do i remove *?

Thanks

Gene

5 REPLIES 5
Reeza
Super User

Assuming the data set is in SAS and the column is character, use the COMPRESS() function to remove the *.

Also assuming you would like that value as numeric, you can nest it with an INPUT function as well. 

 

num_var = input(compress(original_var, '*'), 8.);

Documentation on compress function.

May be worth taking a look at the k and d modifiers if you have more than one character to remove. 

 

 


@geneshackman wrote:

Hi all

My data set has a column of numbers. Some numbers in the column have *, so for example

1
2​
4*
3
2*
5*
2

How do i remove *?

Thanks

Gene


 

geneshackman
Pyrite | Level 9

Hi Reeza.  Thanks for responding. My only concern was that the character I'm removing is the asterisk, "*". I wasn't sure whether SAS would read it as a wild card and remove everything.

Reeza
Super User
* is only a wildcard in certain functions/usages, not all. But in that case you could also look at the k/d modifiers suggested which avoids listing the * entirely.
ballardw
Super User

My question with data like this would be "what does the the asterisk represent?" If there is some meaning that may be needed at a later date perhaps you need some approach other than just removing it.

geneshackman
Pyrite | Level 9
In this case, i can remove * from the numbers column, because i have another column explaining the meaning. So i don't need *.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1558 views
  • 0 likes
  • 3 in conversation