This is not code I have time to write, but what it sounds like is you want
to write a multistep process.
First, query the directory listing from an infile PIPE to get the files that
have the layouts (D_ files?). Or if you know what they'll be called due to
them having a year/quarter indicator or something, you can skip that step
and read them in with a wildcard or something.
Then, write code to parse those files into the layout, and write input code
Then, use that layout [either via SQL SELECT INTO or %include] to use the
input code, creating the infile name from the earlier directory listing
and/or from the layout file's name.
The first part would just be inputting the layout with a fixed layout that
was intelligent enough to determine what's really a valid line and what's
just header junk. Let's say you called the first column 'name' and second
'numchar' (numeric/charater indicator).
The second part would be something like
retain inputstring $5000.;
if _n_ = 1 then input_file = "input";
input_file = catx(' ',input_file,name);
if numchar='character' then
input_file = catx(' ',input_file,'$');
The third part would be just:
infile "whatever your filename is";
give or take.
On Wed, Jan 20, 2010 at 2:01 PM, slightmoon <email@example.com> wrote:
> Sorry, Tom, Let me try one more time. For each quarter in each year, I
> have two types of data.
> D_RC_0300.txt is like this:
> FILE LAYOUT FOR SCHEDULE RC-TABLE
> DATA DELIMITED BY COMMA
> VARIABLE FIELD DEC. VARIABLE
> NAME TYPE POS. DESCRIPTION
> -------------- ------- ----
> SYSTEM Numeric 0 System Code
> DIST Numeric 0 District Code
> ASSOC Numeric 0 Association Code
> MONTH Numeric 0 Month of Report
> YEAR Numeric 0 Year of Report
> UNINUM Numeric 0 System, District, and
> CASH Numeric 0 Cash
> MKTINV Numeric 0 Marketable Investments
> ACTREC Numeric 0 Accounts Receivable
> ACRLNS Numeric 0 Accrual Loans and Leases
> net of
> income and unapplied
> loan payments
> RC_0300.txt file looks like this:
> The output data file I want to create is gonna look like this:
> STSTEM, DIST, ASSOC, MONTH, YEAR, CASH, MKTINV, ACTREC, ACRLNS
> The problem is I have 20 pairs of tables (one with Var names, one with
> numbers) in each quarter in each year (10 years) so I cannot merge
> datafiles manually. I am gonna post my Macro here. It did not run
> after I change Proc Import to Data step.