|
Jeffery,
You need to perform retain on the variables from "5" records and read the
"6/7" records with an output for each pair of them.
Something like:
data foobar;
infile "datafile" lrecl=80 recfm=v truncover;
length rectype $1;
retain company_name '' date .; * You should set the length for these also;
input rectype @;
if rectype not in (5, 6) then do;
abort; /* You have a file format problem here */
end;
if rectype = 5 then do;
input
company_name /* Think about how you are going
to parse the company name if it
is not fixed length or delimited */
date : mmddyy8.
;
end;
if rectype = 6 then do;
input
employee_name /* Think about how you are going
to parse the employee name if it
is not fixed length or delimited */
amount
;
input rectype @;
if rectype ne 7 then do;
abort; /* You have a problem here */
end;
input mealtype;
output;
end;
format date mmddyy10.;
run;
To parse the company/employee names without fixed length or delimited
records, you can read the entire record into a single character variable,
reverse it, look for the first token (scan function) and get the date and
amount out while reversing it back again.
George.
"Jeffrey Cohen" <jcohen@PHEAA.ORG> wrote in message
news:OF4270C742.2F97D958-ON85256A72.006B693C@pheaa.org...
> I'm having a mental block and need some help. I have a file, an example
is
> below:
>
> 5 abc company 6/5/01
> 6 jim smith 100.00
> 7 lunch
> 6 john jones 250.00
> 7 dinner
> 8 350.00
> 5 xyz company 6/8/99
> 6 joe jobs 50.00
> 7 breakfast
> 8 50.00
>
> I need my final record to look like the following. The problem is that for
> every "5" record I may have from 1 to 100 "6/7" combinations.
>
> abc company 6/5/01 jim smith 100.00 lunch
> abc company 6/5/01 john jones 250.00 dinner
> xyz company 6/8/99 joe jobs 50.00 breakfast
> ....
> Thanks.
> Jeff Cohen
> Accounting Systems Analyst
> Pennsylvania Higher Education Assistance Agency
|