Date: Thu, 2 Nov 2006 10:57:14 -0800
Reply-To: Neerav Monga <neerav.monga@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Neerav Monga <neerav.monga@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: reading in multple csv files and exporting to excel via macro
In-Reply-To: <Hqb2h.19159$TV3.18864@newssvr21.news.prodigy.com>
Content-Type: text/plain; charset="iso-8859-1"
Kenneth,
The simplest solution is always the best solution. This is a DOS trick
I didn't know of and it worked perfectly. I can just delete the extra
directory information, read the file into SAS, create a macro and loop
through the import/export statements. This should work, I'll play
around with this.
Thanks.
kenneth_m_lin@sbcglobal.net wrote:
> You could have captured the filenames when you were creating the CSV files
> and dump the list in a SAS dataset.
>
> Here is a completely brainless solution. Open a command prompt, cd to the
> correct directory, then issue the command DIR *.csv /w >> list.txt. The
> file list.txt now contains the list of CSV files and it doesn't even matter
> if it the filenames follow any pattern. You could read in file into a SAS
> datset and use SAS macro to create a list of filenames.
>
> The morale of the story is that SAS isn't the only tool at your disposal.
> Yes, you could do this all in SAS but you'd actually have to read the
> manuals.
>
> "Neerav Monga" <neerav.monga@gmail.com> wrote in message
> news:1162419579.891409.75980@m73g2000cwd.googlegroups.com...
> > Hi everyone,
> > I have about 50 files that are in csv format labelled file1.csv ,
> > file2.csv etc... (however it does skip numbers, eg.. 1-5, then 20-25,
> > they aren't necessarily consecutive numbers). I saved all of them in
> > one folder in windows xp using SAS 9.1.3.
> >
> > I know i can put the proc import/export into a macro and feed the macro
> > the input filename and export file name, however, is there a way to
> > automate this somehow? It would save me a lot of time.
> >
> > I know the non consecutive numbers might be an issue, but they have to
> > stay as labelled. After the file is imported, I need to remove the
> > first four characters in a field in the file (which I can easily do
> > with the substring command), drop the old field with extra characters
> > and then export it.
> >
> > Perhaps there's a way to import / export an entire folder/library at
> > once? That might be the easiest way to go?
> >
> > Any help would be appreciated,
> >
> > TIA,
> >
> > Neerav
> >
|