Date: Thu, 29 Jun 2006 07:10:26 -0700
Reply-To: Rune Runnestø <rune@FASTLANE.NO>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Rune Runnestø <rune@FASTLANE.NO>
Organization: http://groups.google.com
Subject: Reading a string conditionally spread on two lines
Content-Type: text/plain; charset="iso-8859-1"
/*
I don't understand why this piece of code fail.
Only two records are read into the data set TEST.
The values in the second record are partly wrong;
the values in the four last varaibles in record 2
belongs to record 3 in the data file.
And the values in SAKSTITTEL and SAKSTITTEL2 are wrong.
May be is has to do with that not all titles are spread on two lines.
How should I make
the code robust enought to take that into account ?
Regards, Rune
*/
data test ;
attrib
Saksnr length = $10
Arkiv_nokkelkode length = $16
Sakstittel length = $140
Sakstittel2 length = $80
Saksdato length = 8
Siste_dok length = 8
Antall_dok length = 3
Saksansvarlig_person length = $3
;
infile datalines;
input
@'SAKSNR:' saksnr : $
@'ARKIV:' arkiv_nokkelkode : $
@'TITTEL:' sakstittel : $ & sakstittel2 $ &
@'SAKSDATO:' saksdato : ddmmyy10.
@'SISTE DOK.:' siste_dok : ddmmyy10.
@'ANT.DOK:' antall_dok :
@'SAKANSV:' saksansvarlig_person : $
;
format
saksdato
siste_dok ddmmyy10.
;
sakstittel = trim(left(sakstittel)) || ' ' ||
trim(left(sakstittel2));
datalines;
---------------------------------------------------------------------------------------------------------------------------
SAKSNR: 1994000004
ARKIV: 326.12
TITTEL: Title one, line one
line two in title one
SAKSDATO: 04.01.1994 SISTE DOK.: 26.11.2001 ANT.DOK:
26 SAKANSV: ASA
---------------------------------------------------------------------------------------------------------------------------
SAKSNR: 1994000007
ARKIV: 341.9
TITTEL: title two
SAKSDATO: 06.01.1994 SISTE DOK.: 16.03.2001 ANT.DOK:
22 SAKANSV: NAM
---------------------------------------------------------------------------------------------------------------------------
SAKSNR: 1994000008
ARKIV: 326.10
TITTEL: Title three
SAKSDATO: 07.01.1994 SISTE DOK.: 15.05.2003 ANT.DOK:
17 SAKANSV: BOB
---------------------------------------------------------------------------------------------------------------------------
;
run;
proc print; run;
|