Edit a character variable and replace parts with blanks or nulls

Reply
Occasional Contributor
Posts: 18

Edit a character variable and replace parts with blanks or nulls

I am trying to do a find and replace in a character variable.  See sample below:

Original character variable--->      test.test1.test2.test3

Want to edit replace everything starting with the 1st"." and replace with spaces or nulls, so the final variable contains:    test

Any suggestions??

Thanx,

Jim Glover

Super User
Posts: 11,343

Re: Edit a character variable and replace parts with blanks or nulls

Posted in reply to Gloveman71

string = scan(string,1,'.');

you don't mention a variable name so i use string as a generic.

Contributor
Posts: 22

Re: Edit a character variable and replace parts with blanks or nulls

Posted in reply to Gloveman71

In case if you want to replace all the dots(.) then use this :

name_all=tranwrd(name,'.',' ');

Hope this helps !!

Ask a Question
Discussion stats
  • 2 replies
  • 206 views
  • 3 likes
  • 3 in conversation