|
I'm now in front of a computer with SAS, so I can give a more complete
answer. I think you need to do the following things:
1) Compute the record length as indicated by Mike Zdeb
2) Use the LRECL= option in IML when you WRITE the data, as well as when
you read.
3) Almost surely you'll want a different format than 4.0. Maybe BEST8.?
4) To make your life easier, you can use the SYMPUTX routine to create a
macro variable in IML that remembers the record length. You can then use
this macro in the DATA step.
Putting it all together might look like this:
-------
proc iml;
y = j(200, 84);
call randgen(y, "normal"); /* create sample data */
/* compute record length: width=8 plus 2 spaces between values */
len = (8+2)*ncol(y) - 2;
filename output 'C:\DATA.dat';
file output lrecl=len; /* open file with specified record length */
do i=1 to nrow(y);
do j=1 to ncol(y);
put (y[i,j]) best8. + 2 @; /* write values as text */
end;
put;
end;
closefile output;
/* make your life easy: create macro variable with the LRECL value */
print "In DATA step, use LRECL=" len;
call symputx("lrecl_val", len);
call symputx("numVar", ncol(y)); /* read this many vars */
quit;
data temp00;
infile 'C:\DATA.dat' lrecl=&lrecl_val;
input var1-var&numVar;
run;
------
However, I am wondering why you are writing and reading to text files
instead of just writing a SAS data set? Writing a SAS data set will be
faster, will keep the full precision of the values, and will work without
having to mess with LRECL. If you want to write a SAS data set in
SAS/IML, just use the following code:
varNames = "var1":"var&NumVar";
create Temp00 from Y[c=varNames];
append from Y;
close Temp00;
Rick Wicklin
Statistical programming and SAS/IML blog: http://blogs.sas.com/content/iml
|