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
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*
2How do i remove *?
Thanks
Gene
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.
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.
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.