Thursday, December 18, 2008

Replacing a string in a file

Generally, there are two types to replace string in a file.
Classic type: infile / file
C type: functions for external files (fopen, fread, fwrite etc)

Here I want to give two points:
#1:
Classic type can not do in-place update. That means we have to creat a new file.
Note that with SHAREBUFFERS option in infile statement, we can also do in-place update.

#2:
Although C type can do in-place update, string to write can NOT be longer than the string to read.

The two examples at below are helpful.
Classic type:
http://www.sconsig.com/sastips/tip00327.htm
C type:
http://support.sas.com/kb/32/868.html

No comments: