| Date: | Mon, 21 Oct 1996 17:21:26 EDT |
| Reply-To: | Gerry <STATMAN@PACEVM.DAC.PACE.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Gerry <STATMAN@PACEVM.DAC.PACE.EDU> |
| Organization: | Dept of Academic Computing, Pace University |
| Subject: | Look Ahead Methodology: 99% Working ! |
|
SASpros:
This is one of those cases where something is just about working,
but ...
The Task
********
The library systems group asked our help in reformatting a set of
files that lists databases that they make available via web access.
The problem is that for some of the records, the first field, named
JOURNAL, is folded across two or more lines. For example:
Accountancy 0001-4664 1/93 1/89
The Accountant's Magazine 0001-4761 1/93 B 1/82
Incorporated into CA Magazine
(Scotland) 6/93
Accounting and Finance 0810-5391 5/93 5/94 B 5/82 11/91
The records for "Accountancy" and "Accounting and Finance" have JOURNAL
fields that fit on one line and aren't a problem. The second record,
"The Accountant's ...", has a JOURNAL field that is "folded" onto the
the next two lines.
The solution requires the program to "look ahead" to the next record to
see if the first position is filled, indicating a record where JOURNAL
is on one line, or blank, indicating that the JOURNAL field is folded
across 2 or more lines.
On records that have a JOURNAL field that is "folded", a some percentage
DO have the first position filled, but the rest of the record is blank.
This condition is handled by the part of the test on the IF statement:
"(RCHK1 ^= ' ') & (Compress(RCHK2) = '') ..." .
The data, once processed, will be written to a flat file, downloaded
to a PC and reside in a MS-ACCESS database.
The program that processes these files works (on the test data below)
except for a quirk involving the last record in the file.
The Problem
***********
The program attached below almost works, except that it will not output
the last record in the file. According to the SASLOG, all of the records
in the file are read in properly.
I thought the code (LASTREC: Output LIBRARY) after the first output
statement, which is executed at EOF (EOF= coded on the INFILE), would
output the last record -- it doesn't !
I'm sure I must be overlooking something obvious, or that I missed in
the manual, but for the life of me, I can't find it and its driving
me crazy !
The program is run with SAS v6.08 TS430 under the VM/ESA operating
system. SAS v6.09E will be available in about a week. The program and
a "short" datafile, representative of the actual data (80 char, fixed
length record) are attached. The code contains no OS dependencies.
I apologize for the length of this note, but when asking for help, I
think it is better to provide too much information than not enough.
Any and all help will be gratefully appreciated -- now where's that
bottle of tylenol !
-Gerry
------------------------------------------------------------------------
Gerard T. Pauline |
Programmer / Analyst |
Pace University | Phone: (212) 346-1706
Dept of Academic Computing | Internet: Gerry @ Pace.Edu
1 Pace Plaza, Office Y-25 | Bitnet: Gerry @ Pacevm
New York, NY 10038 | Web: http://www.pace.edu/acadcomp
-------------------------------- Program -------------------------------
Filename INPDATA 'LIBRARY DATABASE A1' ;
Options LS=95 NODATE ;
Data LIBRARY (Keep=JOURNAL RECORD) ;
Infile INPDATA Eof=LASTREC ;
Length JOURNAL $ 200
RECORD $ 41 ;
Array JTXT {5} $ 38 _Temporary_ ;
Array RTXT {5} $ 41 _Temporary_ ;
I = 1 ; /* Initialize Array Index */
JTXT{2} = '' ; /* Blank Out Array Elements From Previous */
JTXT{3} = '' ; /* Record, Element 1 Is Always Populated */
JTXT{4} = '' ; /* In Each Array */
JTXT{5} = '' ;
RTXT{2} = '' ;
RTXT{3} = '' ;
RTXT{4} = '' ;
RTXT{5} = '' ;
Do While (1) ;
/*--- Read In Current Record, "Look Ahead" To The Next Record ---*/
Input @1 JTXT{I} $Char38. @40 RTXT{I} $Char41. /
@1 RCHK1 $1. @40 RCHK2 $Char41. @@ ;
If ((RCHK1 = ' ') |
((RCHK1 ^= ' ') & (Compress(RCHK2) = ''))) Then
Do ; /* Journal Field Is "Folded" */
I + 1 ; /* Increment The Array Subscript */
Continue ; /* Populate The Next JTXT Element */
End ;
Else
Leave ; /* Journal Field Is All On One Line */
End ; /* End DO WHILE (1) Loop */
/*--- Form The JOURNAL & RECORD Variables, And Output To Dataset ---*/
JOURNAL = Trim(JTXT{1}) || ' ' || Trim(JTXT{2}) || ' ' ||
Trim(JTXT{3}) || ' ' || Trim(JTXT{4}) || ' ' ||
Trim(JTXT{5}) ;
RECORD = RTXT{1} ;
Output LIBRARY ;
Return ; /* Not At E-O-F Yet */
LASTREC: Output LIBRARY ; /* Account For The Last (?) Record ... */
/* At Least I Thought I Was ! */
Return ;
Run ;
Proc PRINT Data=LIBRARY ;
Var JOURNAL ;
Title 'Full-Text Databases In The Pace Libraries' ;
Run ;
-------------------------------- Datafile ------------------------------
3X!400 Systems Management 1070-6097 5/93
Now: AS!400 Systems Management 12!95
;Formerly: Systems 3X-400
A+ 0740-1590 1/89
Incorporated into inCider 4/89;The
#1 Apple II Magazine
ABA Banking Journal 0194-5947 1/93 1/93 B 1/82 1/89
ABACUS 0001-3072 9/93 B 6/82
The Academy of Management Executive 0896-3789 2/93 2/94 B 2/92
Academy of Management Journal 0001-4273 2/93 2/93 B 3/89 3/92
Academy of Management Review 0363-7425 1/93 1/93 B 1/89 1/92
Acadiana, Inc. B 5/85
Ceased indexing 12/85;Formerly: New
Business 3/85
Accountancy 0001-4664 1/93 1/89
The Accountant's Magazine 0001-4761 1/93 B 1/82
Incorporated into CA Magazine
(Scotland) 6/93
Accounting and Finance 0810-5391 5/93 5/94 B 5/82 11/91
Accounting, Organizations and Society 0361-3682 2/93 2/89
Accounting Review 0001-4826 1/93 1/89
Across the Board 0147-1554 1/93 1/93 B 1/82 11/90
Administration in Social Work 0364-3107 1/93 3/92
Administration & Society 0095-3997 2/93 2/93 B 5/85 11/91
Administrative Management 0001-8376 M B 1/82
Now: Office Administration and
Automation 1/83
Administrative Science Quarterly 0001-8392 3/93 3/93 B 3/82 3/89
Advanced Imaging 1042-0711 10/93 10/93 B
Incorporates AVC Presentation for
the Visual Communication 8/93
Advantage 0739-5515 B 1/85
Now: Nashville Business and
Lifestyle 9/90;Ceased indexing
Advertising Age 0001-8899 1/93 B 1/84
Advertising World 0163-9412 B 2/82
Now: International Advertiser 9/85
ADWEEK Eastern Edition 0199-2864 1/93 1/93 B 1/89 1/89
ADWEEK Western Advertising News 0199-4743 1/93 1/93 1/89 1/89
Adweek's Marketing Week 0892-8274 1/89 1/89
Now: Brandweek 7/92
AEI Economist 0149-9785 1/89
African Business 0141-3929 1/93 1/94 B 8/92
Aftermarket Business 0892-1121 1/93 1/93 1/89 1/91
Formerly: Home & Auto 7/86
Agency Sales Magazine 0749-2332 1/93 1/93 1/89 1/91
Agribusiness 0742-4477 1/93 1/92
Agrichemical Age 0044-6769 1/89
Ceased Publication 7/91
Air Conditioning, Heating & 0002-2276 1/93 1/93 B 1/82 1/89
Refrigeration News
Air Force Comptroller 0002-2365 B 1/82
Air Progress 0002-2500 1/93 1/89
Air Transport World 0002-2543 1/93 1/93 B 1/82 1/88
Akron Business and Economic Review 0044-7048 B 3/82
Alaska Business Monthly 8756-4092 1/93 1/93 B 1/85 2/89
Alberta Business 0827-2603 B 12/84
Suspended publication 6/93
American Banker 0002-7561 4/95
American Business Law Journal 0002-7766 2/93 2/93 1/89 6/91
American City & County 0149-337X 1/93 1/93 M B 1/82 8/89
American Demographics 0163-4089 1/93 B 1/82
American Druggist 0190-5279 1/93 12/93 1/89
American Economic Review 0002-8282 3/93 3/89
American Economist 0569-4345 3/93 3/93 B 3/89 9/91
American Federationist 0149-2489 M B 2/82
American Forests 0002-8541 1/93 1/93 M B 1/82 1/89
American Journal of Agricultural 0002-9092 2/93 2/89
Economics
American Journal of Small Business 0363-9428 B 3/82
Now: Entrepreneurship: Theory and
Practice, 9/88
American Medical News 0001-1843 1/93 1/93 1/89 1/90
American Metal Market 0002-9998 4/95 4/95
American Paint & Coatings Journal 0098-5430 1/93 1/93 B 1/82 1/92
Incorporates American Paint &
Coatings Journal Convention Daily
American Printer 0744-6616 1/93 1/93 1/89 2/90
Formerly: American Printer and
Lithographer, 5/82
American Review of Public 0275-0740 3/93 3/93 B 3/82 3/89
Administration
Suspended publication 1/84 to 12/87
American Salesman 0003-0902 1/93 1/93 B 2/82 1/89
American Shipper 0160-225X 1/93 1/93 B 10/83 3/90
America's Community Banker 4/95 5/95 B
Formerly: Savings & Community Banker
4/95
America's Network 2/94 2/94
Formerly: Telephone Engineer &
Management 2/94
Amusement Business 0003-2344 1/93 1/93 B 1/89 1/89
Annual Institute on Securities 0195-5756 1/93 1/89
Regulation
Antitrust Bulletin 0003-603X 3/93 3/93 B 6/82 6/91
Antitrust Law and Economics Review 0003-6048 6/94 1/89
Antitrust Law Journal 0003-6056 1/93 1/93 B 3/89 6/91
Appliance Manufacturer 0003-679X 1/93 1/93 B 1/84 1/89
Applied Economics 0003-6846 1/93 1/93 B 2/82 10/91
|