Date: Mon, 29 Aug 2005 16:24:58 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: reading similarly named files automatically
Beth,
Depending upon the operating system you are on, you could incorporate
something like the following:
%let dir2use=c:\;
filename dirlist pipe "dir &dir2use.*.xml /B";
data newfiles;
length dirname $70;
infile dirlist truncover;
input dirname &;
if index(dirname,'200508');
run;
Art
-----
On Mon, 29 Aug 2005 11:54:15 -0600, Elizabeth Newsom
<Elizabeth.E.Newsom@KP.ORG> wrote:
>I am hoping someone can look at the problem I'm having and tell me how I
>can (easily) fix it. Although this involves reading XML files, it's more
a
>question on how to read in a series of files, automatically.
>
>I am reading a bunch of XML files into SAS. Generally there's 1 file per
>day (yyyymmdd in the middle of the XML file name) except in this case on
>8/12/2005, where there are 3 files. Here's a sample of their names:
>
>KPCO20050811T123.XML
>KPCO20050812T122.XML
>KPCO20050812T145.XML
>KPCO20050812T255.XML
>KPCO20050813T344.XML
>KPCO20050814T111.XML
>
>I thought the following code would read them ALL in (you can ignore the
>xmlmap= part):
>
>%macro readxml(filename);
>libname test xml "path1/&filename..xml"
> xmlmap="path2/xml_map_final.map";
>
>* Many more lines of SAS code go here;
>%mend readxml;
>
>%macro xml;
>%DO I=11 %to 14;
>%readxml(KPCO200508&i.*,xml&i);
>%mend xml;
>%xml;
>
>But this code only reads ONE of the files from 8/12/2005 and then proceeds
>to read the 8/13/2005 file.
>
>Any way to fix this? It needs to be automatic because I'll be doing this
>basically on a monthly basis, so I want it automated.
>
>Thanks for any help,
>
>Beth
>
>Beth Newsom
>Clinical Research Unit
>Kaiser Permanente of Colorado
>Phone: 303-636-3128
>Fax: 303-636-3149
>
>CONFIDENTIAL AND PRIVILEGED: This communication contains information only
>for the use of the individual or entity to which it is addressed. If you
>are not the intended recipient or a KP employee responsible for delivering
>the communication to the intended recipient, please be aware that you are
>strictly prohibited from sharing, distributing or copying this
information.
>If you have received this communication in error, please notify the
>individual who sent this immediately at the telephone number below to
>arrange the return or proper delivery of this document.
|