0

I got binary data from Oracle (doc file) and devided it into parts (cause of lenght limits). Then I need to put this binary data to file (create a file) I do the next:

data _null_; 
  set data; 
  file 'c:\fileout.doc' lrecl=4000; 
  put @1 blob_1 $HEX4000
      @2 blob_2 $HEX4000     
      @3 blob_3 $HEX4000      
   [etc]
  ;
run;

When i open it i see binary code. How can I put binary data into file and see my document in a correct way?

Thank you.

  • I assume this is related to [this question](http://stackoverflow.com/questions/32542486/import-blob-through-sas-from-oracle-db) - did you ever get a solution there? I think that really duplicates this question - if you solve that one, this one is also solved. – Joe Sep 14 '15 at 17:24
  • it a kind different question. This question is about saving data to file, othere is getting data from Oracle DB – Donald William Glossfield Sep 14 '15 at 20:10
  • But it seems to me that it's the same root problem: you don't know how to get it out of the blob in a readable format. – Joe Sep 14 '15 at 20:11

1 Answers1

1

You need to use the correct RECFM on the FILE statement. Also use the proper format on the PUT statement.

data _null_; 
  set data; 
  file 'c:\fileout.doc' RECFM=N ;
  array blob blob_1-blob_3 ;
  do i=1 to dim(blob);
      put blob(i) $char2000. ;
  end;
run;
Tom
  • 47,574
  • 2
  • 16
  • 29
  • Thank you very much! Can you tell me how to write this step if i have number of rows?(need to create n - numbers of different files, and file name have to be the on of the variable – Donald William Glossfield Sep 15 '15 at 09:29
  • Use the FILEVAR option on the FILE statement to tell it which variable in the data set has the name of the file to write to. You probably have to have a variable that indicates how many characters (bytes) to write for each observation. – Tom Sep 15 '15 at 11:56
  • I have it, it is dbms_lob.getlength – Donald William Glossfield Sep 15 '15 at 12:25