Date: Wed, 9 Mar 2011 10:28:05 -0500
Reply-To: Nat Wooding <nathani@VERIZON.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <nathani@VERIZON.NET>
Subject: Re: problems importing datetimes from csv files
In-Reply-To: <201103091416.p29BljtL006564@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="US-ASCII"
Nuria
The loop is invoked when you encounter either the very first record of the
first file or you come to the start of one of the subsequent files. As you
said, it extracts the name of the calf from the filename and saves both the
filename and the calf name.
Then, the EOV value, which signals that you have reached the beginning of a
file, is reset to 0. Otherwise, it will stay at a value of 1.
You then skip the two header records.
The delete is used to keep you from outputting an obs with missing values.
Does this help.
Nat Wooding
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Nuria
Chapinal
Sent: Wednesday, March 09, 2011 9:17 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: problems importing datetimes from csv files
I am still having trouble understanding what this loop of the code does,
though. I know what the calf = input(etc...) does because I created it. It
is taking a bit of the filename.... but the loop itself... I can't figure
it out....
input @;
if _n_ eq 1 or eov then do;
calf =input( scan (input (scan(fname,-1,'_'), $12.),1), 12.);
retain filename calf;
eov = 0;
input #2;
delete;
end;
in the final code:
filename FT46F001 'C:\Users\nuria\Desktop\hobo\c\*.csv' lrecl=256;
data nc;
length fname $256;
infile FT46F001 dlm=',' dsd eov=eov filename=fname truncover ;
input @;
if _n_ eq 1 or eov then do;
calf =input( scan (input (scan(fname,-1,'_'), $12.),1), 12.);
retain filename calf;
eov = 0;
input #2;
delete;
end;
input obs: 9. dtx:$30. (y z) (:9.) ;
date= input(scan(dtx,1,' '),ddmmyy8.);
time = input (substr (dtx, 10, 14), time12.);
format date date.;
format time time.;
hour =hour (time);
run;
|