|
Hi Raymond,
You define a variable Subject with a length of 15. If the first observation is read, the actual length of the subject is shorter, the end-of-line directly follows the Subject. Thus SAS default tries to read the complete field from the following line (FLOWOVER). Add the option TRUNCOVER to the INFILE statement and consult your doc, why that is necessary in this case. Also try switching «&» and «$15.» in your INPUT statement, see your doc on List Input.
Regards - Jim.
--
. . . . . . . . . . . . . . . .
Jim Groeneveld, MSc.
Biostatistician
Science Team
Vitatron B.V.
Meander 1051
6825 MJ Arnhem
Tel: +31/0 26 376 7365
Fax: +31/0 26 376 7305
Jim.Groeneveld@Vitatron.com
www.vitatron.com
My computer has the solutions, I have the problems.
[common disclaimer]
-----Original Message-----
From: Raymond [mailto:ray6060@HOTMAIL.COM]
Sent: Friday, October 31, 2003 05:42
To: SAS-L@LISTSERV.UGA.EDU
Subject: a question about & sign in SAS programming
The original dataset p3.dat is as follows:
BARBARA 2 ENGLISH
CAROL 2 SCIENCE
CAROL 3 ENGLISH
CAROL 4 MATH
DONALD 1 ART
JAMES 4 MATH
JOYCE 5 HOME ECONOMICS
JOYCE 6 SCIENCE
MARY 2 MECHANICS
PHILIP 1 HOME ECONOMICS
PHILIP 3 MATH
WILLIAM 2 SCIENCE
SAS codes:
DATA study;
INFILE 'p3.DAT';
INPUT NAME $ year SUBJECT & $15.;
proc print;
RUN;
Since there is imbedded blanks in the values of variable SUBJECT, so &
sign should be used to avoid messed output. when & sign is taken off,
the output
is as follows,
Obs NAME YEAR SUBJECT
1 BARBARA 2 CAROL 2 SCI
2 CAROL 3 CAROL 4 MAT
3 DONALD 1 JAMES 4 MAT
4 JOYCE 5 HOME ECONOMICS
5 JOYCE 6 MARY 2 MEC
6 PHILIP 1 HOME ECONOMICS
7 PHILIP 3 WILLIAM 2 SCI
Why is this? Since the imbedded blank occurs from the 7th record in
the original dataset, why the first value of SUBJECT--ENGLISH is not
read at all?
How does SAS pointer move in this situation?
|