Following on from my question yesterday, I am now successfully reading data from a binary file, but I can only do this with the random access style syntax along the lines of "input >n" to read something at byte position n.
If I try syntax like " input <8 x IEEE8.; " to read the next 8 bytes as an IEEE double, it does not advance the file pointer, so any similar input statements that follow keep re-reading the same 8 bytes. I have tried using a trailing @ but this makes no difference. Is there perhaps a hold control for binary files that I am not aware of?
Also, is there a way of reading a block of data into a matrix, instead of reading numbers one at a time?
I don't know. I have never read binary data into IML variables.
In my experience, it is easier to use the DATA step for operations such as this. If this is something that is one step of a larger IML program, you can use the SUBMIT-ENDSUBMIT block to call the DATA step from within PROC IML. You can even pass parameters from IML variables into the DATA step.
I think I am probably sticking with a pure IML solution as I have something that works, it's is just not quite as fast as I hoped. The binary files are large, around 350MB to 1GB. Each contains 5 matrices and 5 vectors (not all of which will be required), and it just seemed more efficient to read what I want directly into IML for further processing.
OK. One possible idea regarding the speed: If you need to run several programs on the same data, you can read the binary data into matrices once, then save them as a SAS data set (preferred) or use the STORE statement to save the matrices. If you do that, subsequent access of the data will be faster. Of course, if you are trying to read data that are generated every morning by some non-SAS process and only analyzed by one IML program, this idea won't save you any time.
Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.
Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.