BookmarkSubscribeRSS Feed
Tasha
Calcite | Level 5
I would like to update values in an external file. The file is not a fixed length. The code drops the first character of the next line after it updates.. What will be a good way to do this?

Here is the code I use to update:
data _null_;
infile file lrecl=400 truncover sharebuffers pad;
file file;
input @72 id $ 9.;
set upd key=id/unique end=done;
if _IORC_=0 then put _infile_ @81 item;
else do;
_error_=0;
end;
run;
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You have a hardcoded LRECL, yet you say that the incoming file "is not a fixed length". Also, your PUT statement does not show a format/length for the variable ITEM.

http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000171874.htm

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic/post:
update external file inplace site:sas.com
Tasha
Calcite | Level 5
Thanks!!

LRECL for the max length even though the lines are different lengths.
Even with the variable length, the problem still exists..
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
I believe that you will need to read the file, writing to a new file, then replace (not in-place though) the original file. Suggest you review the DOC references, as well. And again share any updated/modified code with the forum as a post-reply, ideally in your SAS execution log, not just the code piece.

Explain the SAS environment and where the external file resides for additional guidance.

Also, I question the use of PAD, if you have variable-length data to copy - each PUT will pad the output record to the LRECL= amount specified, I believe. You should start with the bare minimum parameters and go from there.

Scott Barry
SBBWorks, Inc.

Message was edited by: sbb Message was edited by: sbb
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1630 views
  • 0 likes
  • 2 in conversation