LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 9 Mar 2011 07:43:32 -0800
Reply-To:   Núria Chapinal <nchapinal@YAHOO.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Núria Chapinal <nchapinal@YAHOO.COM>
Subject:   Re: problems importing datetimes from csv files
Comments:   To: Nat Wooding <nathani@VERIZON.NET>
In-Reply-To:   <4E487466A0C04EE48B5EC34E51C4E7B6@D1871RB1>
Content-Type:   text/plain; charset=iso-8859-1

Thanks so much!   The filename does not apper in the  imported SAS dataset. I do not see where it is deleted in my code. I do not need it, but I was wondering why it wasn't there....

  Núria Chapinal Postdoctoral fellow Animal Welfare Program, University of British Columbia Department of Population Medicine, University of Guelph

--- On Wed, 3/9/11, Nat Wooding <nathani@VERIZON.NET> wrote:

From: Nat Wooding <nathani@VERIZON.NET> Subject: Re: problems importing datetimes from csv files To: SAS-L@LISTSERV.UGA.EDU Received: Wednesday, March 9, 2011, 10:28 AM

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;


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