|
|
Re: Infile question: read the last observation #5
UNIX has a "tail" command, terribly handy at a time like this, to pull the
last X lines of a sequential file. I imagine Windows "tail" functionality
is available via CYGWIN ( http://www.cygwin.com/ ), but for those not
wanting to go to those lengths, it appears as though "tail" functionality is
available for Windows XP / 2003 as well.
http://malektips.com/xp_dos_0001.html
That being the case, the last line may be read by using the FILENAME blah
PIPE stuff ( untested ):
filename last_line pipe "tail -1 'c:\your_dir\your_file'";
data new;
infile last_line ;
input clus days freq days1 days2 days3;
run;
-----Original Message-----
From: Charles Patridge [mailto:charles_s_patridge@PRODIGY.NET]
Sent: Monday, August 23, 2004 3:36 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Infile question: read the last observation
Paul,
Using a test file - here is what I got for results:
options fullstimer;
%let myfile = c:\download\sastest.txt;
data last_record ;
length ml $3. order $6. dataname $8. datalabel $50.;
array x(*) x1-x61;
infile "&myfile" delimiter="!" dsd end = eof missover lrecl=1024
firstobs=4;
input ml order dataname datalabel x1-x61;
if eof ;
run ;
The infile "c:\download\sastest.txt" is:
File Name=c:\download\sastest.txt,
RECFM=V,LRECL=1024
109716 records were read from the infile "c:\download\sastest.txt".
The minimum record length was 1024.
The maximum record length was 1024.
One or more lines were truncated.
The data set WORK.LAST_RECORD has 1 observations and 65 variables.
DATA statement used:
real time 10.35 seconds
user cpu time 9.70 seconds
system cpu time 0.06 seconds
Memory 131k
***you use this: ;
data last_record ;
length ml $3. order $6. dataname $8. datalabel $50.;
array x(*) x1-x61;
infile "&myfile" delimiter="!" dsd end = eof missover lrecl=1024
firstobs=4;
input @;
if eof;
input ml order dataname datalabel x1-x61;
run ;
The infile "c:\download\sastest.txt" is:
File Name=c:\download\sastest.txt,
RECFM=V,LRECL=1024
109716 records were read from the infile "c:\download\sastest.txt".
The minimum record length was 1024.
The maximum record length was 1024.
One or more lines were truncated.
The data set WORK.LAST_RECORD has 1 observations and 65 variables.
DATA statement used:
real time 7.93 seconds
user cpu time 6.79 seconds
system cpu time 0.14 seconds
Memory 131k
HTH,
Charles Patridge
http://www.sconsig.com
Would be nice if there was a faster way to get last record of an external
file without knowing the # of records in an external file.
------------------------------------------------------------
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.
Ce courrier �lectronique est confidentiel et prot�g�. L'exp�diteur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) d�sign�(s) est interdite. Si vous recevez ce courrier �lectronique par erreur, veuillez m'en aviser imm�diatement, par retour de courrier �lectronique ou par un autre moyen.
============================================================
|
|
0
|
|
|
|
Reply
|
harry.droogendyk1 (872)
|
8/23/2004 7:51:32 PM |
|
|
0 Replies
50 Views
(page loaded in 1.261 seconds)
Similiar Articles: Large file problems - block pattern - comp.lang.awk... Post Question ... REBUIL/ { print } ' 2/ The infile is 260573bytes, but awk only can read ... f;f&&/^$/{exit}' file Print last block (since you're ... Import delimited (.txt) file -- URGENT PLEASE - comp.soft-sys.sas ...... into SAS withy partial success. I can read ... data foo; length NAME LAST CITY .. .. .. ; infile "/.../MYFILE.txt ... Friday, December 18, 2009 13:00 Subject: Re ... Reading a big .CSV file into SAS - comp.soft-sys.sas... data mydataa; infile in1 DLM=',' missover; input Site $ Date $ Case $ myinfof1 $ LAST $ FIRST ... records into excel from sas 5 316 I have large ... Reading ... Error in reading compressed file - comp.soft-sys.sas... SAS-L@LISTSERV.UGA.EDU Subject: Re: Error in reading ... before doing so, I have a comment, a question ... If I manually delete the last line then SAS can read the file ... Korn shell script returns read: bad file unit number - comp.unix ...... Bourne shell -ksh script is Korn shell infile ... programming.itags.org: Unix & Linux question: Korn shell script returns read ... Apr 2008 18:22:00 GMT with 945 bytes, last comp.soft-sys.sas - page 50... to create file1 through > file4 but only read ... Re: version updates 0 5 (7/11/2003 8:21:38 PM) > From: SAS User [mailto ... characters as delimiters such as '[~'. > > infile ... Solaris 10 update 05/08 is released - comp.unix.solarisAfter I rebooted into 5/08 I had fix an ... problem is more closely related to the observation ... Last week, the Solaris 10 05/08 (Update 5) Patch Bundle was released on SunSolve. 52-week high rolling window -- HELP!!!!! - comp.soft-sys.sas ...If you're not familiar with the hash object: Besides ... datastep/dot/hash-tip-sheet.pdf data have; infile ... Just two links dealing with this hashexp question: http ... creating a counting variable - comp.soft-sys.sas... after x1 - x17 are populated for this observation ... of x:)): length() gives the position of the last ... Re: %sysfunc question - comp.soft-sys.sas Macro SAS - counting ... Reading a Line from a file - comp.soft-sys.matlab... we're in case 2 and you're now ready to read ... to a conclusion on that question you ... soft-sys.sas I started by reading in this file so that each line is an observation ... Infile question: read the last observation - sas - Mofeel Groupssas, Infile question: read the last observation . comp.soft-sys.sas - The SAS ... 2004 3:36 PM To: XXXX@XXXXX.COM Subject: Re: Infile question: read the last observation ... question on INFILE data - sas - Mofeel GroupsIt looks like you're trying to read 19 characters from a line that ... Infile/Input question. 2. Infile question: read the last observation Hi all, If I want to read the last ... 7/18/2012 4:16:15 PM
|
|
|
|
|
|
|
|
|