Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change characters at specific position in a string in SAS

Tags:

sas

IS there a function to change letters at a given index in SAS?

For example if my string is

string1 = 'abcd1234efgh'

I want to do somehing like:

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

to produce

'abcdzzzzefgh'

like image 987
dwjohnston Avatar asked Oct 26 '25 03:10

dwjohnston


1 Answers

Yes, substr() = is what you're looking for. See here for details.

substr(string2, 5) = 'zzzz';

The substr(variable,position<,length>) = function can also take an third argument to define the length of the segment to be replaced.

like image 189
SRSwift Avatar answered Oct 29 '25 09:10

SRSwift



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!