LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 26 Sep 2008 05:47:15 -0700
Reply-To:     "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Organization: http://groups.google.com
Subject:      Re: How to Read Row Oriented External Files?
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=windows-1252

On Sep 26, 2:35 am, siigm...@yahoo.com wrote: > How to Read Row Oriented External Files? > I have a txt file where all the information is stored in one row. On > record contains 152 variables separated by space. The first record > starts at several positions into the line, position 1970 and lasts > until 3339. The following records have the same length as the first > one. > > Normally, in the external files I have to read into SAS, the records > are stored one in each row. For that purposes the following program is > fine. > DATA out1_9; > INFILE "f:\SAS\out1.dat" LRECL=3939 FIRSTOBS=1; > INPUT > @1970 t1 6. > @1976 t2 13.5 > @1989 t3 13.5 > . > . > . > @3926 t152 13.5 > ; > RUN; > > All on one long line: > nspec = 6…………… 1 0.00000 50.11175 0.00000 0.00000 > 2 0.00000 50.11175 0.00000 0.0000….. > > The obstacle is to modify this program or make another program to > repeat along the row by a %DO sentence/loop.

There is no need for macro here. The input @ operator accepts a variable name, so you can manipulate the value of that variable to dynamically change where you are inputting from.

This will read three fixed sized records that are in the same input line:

offset=1970; do count = 1 to 3; input @(offset+0) t1 @(offset+6) t2 @(offset+19) t3 ... ; offset+1970; end;

-- Richard A. DeVenezia http://www.devenezia.com


Back to: Top of message | Previous page | Main SAS-L page