For example, PNG file d:\aaa.png, Now I want to use SAS to convert d:\aaa.png binary file into a hexdump. Thank you. In R,redBin function can do it.
Asked
Active
Viewed 471 times
1 Answers
0
This should do what you are looking for. It reads the file one character at a time and writes the HEX representation to the outfile.
%let infile = "C:\temp\SGPlot.png";
%let outfile = "c:\temp\out.txt";
filename infile &infile;
filename outfile &outfile;
data _null_;
infile infile recfm=n;
file outfile recfm=n;
format c $1.;
input c $ @@;
put c hex. @@;
run;

DomPazz
- 12,415
- 17
- 23
-
Can you upload your file SGPlot.png, I will paste the reslut from another software. Thank you! – stata Nov 24 '13 at 22:07
-
I cannot upload my png and reslut file. Can you tell me your email. I will send these files to you. You may upload these files. Thanks! – stata Nov 24 '13 at 22:20
-
just use your file and compare the output form SAS and R. I don't understand why you need my file. – DomPazz Nov 24 '13 at 22:30
-
max.bytes<-50000000;dat<-readBin("c:/data/mpg.png", what="raw", size=1, signed=TRUE, endian="little",n=max.bytes); Your sas results were different with R results. – stata Nov 24 '13 at 23:06
-
put c hex. @@; How to put uppercase into lowercase? – stata Nov 25 '13 at 03:09
-
Your sas code wasn't correct because the results were different with R results. – stata Nov 25 '13 at 17:31