[R] Reading sas7bdat files directly

Roger DeAngelis(xlr82sas) rdeangel at amgen.com
Tue Mar 2 03:06:15 CET 2010


Hi,

  It looks like we may need to swap bytes(little endian to big endian). I
will look into it tonight.

  As a side note, SAS reserves 28 floats for missing values. It should be
easy to convert these to NaN on input to R.

You can test this in SAS by converting the 16 char floats to ieee8. in SAS
and doing a put. The result will be A, B...Z, . and _.

SAS code that produced the listing is below.

Here are the floats that map to the 28 missing values in SAS

A  FFFFFD0000000000 
B  FFFFFC0000000000 
C  FFFFFB0000000000 
D  FFFFFA0000000000 
E  FFFFF90000000000 
F  FFFFF80000000000 
G  FFFFF70000000000 
H  FFFFF60000000000 
I  FFFFF50000000000 
J  FFFFF40000000000 
K  FFFFF30000000000 
L  FFFFF20000000000 
M  FFFFF10000000000 
N  FFFFF00000000000 
O  FFFFEF0000000000 
P  FFFFEE0000000000 
Q  FFFFED0000000000 
R  FFFFEC0000000000 
S  FFFFEB0000000000 
T  FFFFEA0000000000 
U  FFFFE90000000000 
V  FFFFE80000000000 
W  FFFFE70000000000 
X  FFFFE60000000000 
Y  FFFFE50000000000 
Z  FFFFE40000000000 
_  FFFFFF0000000000 
.  FFFFFE0000000000 

data mis;                                                               
retain A .A B .B C .C D .D E .E F .F G .G H .H I .I J .J K .K L .L M .M 
       N .N O .O P .P Q .Q R .R S .S T .T U .U V .V W .W X .X Y .Y Z .Z 
      _ ._ DOT .;                                                       
array mis[28] A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ DOT;
  do idx=1 to 28;                                                       
     hex=put(mis[idx],ieee8.);                                          
     xeh=put(hex,hex16.);                                               
     put @1 mis[idx] @6 xeh;                                            
  end;                                                                  


-- 
View this message in context: http://n4.nabble.com/Reading-sas7bdat-files-directly-tp1469515p1574506.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list