Changing characters at a specific position in a string in SAS

Is there a function to change letters with a given index in SAS?

For example, if my line is

string1 = 'abcd1234efgh'

I want to do something like:

string2 = somefunction(string1, 5, 'zzzz');

for creating

'abcdzzzzefgh'

+3


source to share


1 answer


Yes, substr() =

that's what you are looking for. See here for details .

substr(string2, 5) = 'zzzz';

      



The function substr(variable,position<,length>) =

can also take a third argument to determine the length of the segment to replace.

+4


source







All Articles