[R] Import ASCII data using a .sas program

Donald Catanzaro, PhD dgcatanzaro at gmail.com
Wed Apr 14 19:02:18 CEST 2010


Good Day,

I have several ASCII data files that I would like to import into R.  
They all have a SAS import file which is used to bring the data into SAS 
and I am hoping to use this to bring the data into R.  There are lots of 
variables involved and the ASCII data file is 2308 columns long so I 
would certainly prefer to figure out a smart way of converting the data 
to R.

The ASCII data is a long stream of numbers (no field separators or 
delimiters) while the SAS import file looks like:

libname mine 'c:\';
data mine.fh4;
infile 'd:\fh4.txt' lrecl=2309;
input
    perstat1 $1-2
    linenum $3-4
    I_wave1 $5-5
    bnocost1 $6-10
    bnosta1 $11-12

So SAS uses the position of the ASCII character to determine what 
variable the data should be in while the SCAN or the READ. FWF function 
of R uses the width of the column.

Does anyway have a smart and/or automated way of moving my ASCII data 
into R using this .SAS program  ?

-- 
-Don 

Don Catanzaro, PhD                  
Landscape Ecologist
dgcatanzaro at gmail.com
16144 Sigmond Lane
Lowell, AR 72745
479-751-3616



More information about the R-help mailing list