SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 658|回复: 3
打印 上一主题 下一主题

语法错误?

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2010-8-21 01:01:02 | 只看该作者

语法错误?

请教各位前辈,最近在合并档案时一直出现错误讯息,但我找到好久却一直不知哪边错误,可以帮我看一下是哪出错了吗?谢谢!

原本之语法
data both;
infile 'e:\ddd\012.txt';
input a $1-2 b $3-4 c $5-6 sno 7-14 no $15-20 time 21-26 execution 27 buy 28 sell 29 d 30 e 31 f 32 g 33 p1 34-39 q1 40-47 p2 48-53 q2 54-61 p3 62-67 q3 68-75 p4 76-81 q4 82-89 p5 90-95 q5 96-103 p6 104-109 q6 110-117 p7 118-123 q7 124-131 p8 132-137 q8 138-145 p9 146-151 q9 152-159 p10 160-165 q10 166-173 p11 174-179 q11 180-187 date 188-195;
run;

data book;
infile 'e:\abc\bbb1.txt';
input sn $1-6 oq 7-14 op 15-20 type $21 odate 22-29 otime 30-37 eq $38-45 ep $46-51 edate $52-59 etime $60-65 bs $66 or $67 sax $68 age 69-70 sax1 $71 ctype $72 mtype $73 tra $74 tel $75 cell $76 bir $77-84 pi $85 wealth 86-93  max 94-101 flag $102 id3 $103-108 date 109-117  Rd 118-125 .4 Rw 126-133 .4 Rm 134-141 .4 MRd 142-149 .4 MRw 150-157 .4 MRm 158-165 .4 id4 $166-171 date1 172-179  p 180-187 .2 betaM 188-195 .4 betaY 196-203 .4;
if date<20100609;if sn ne ' ';
RUN;


PROC SQL;
CREATE TABLE book2 AS
SELECT book.sn, book.oq, book.op, book.type, book.odate, book.otime, book.ep, book.eq, book.bs, book.or, book.sax, book.age,book.sax1,book.ctype,book.mtype,book.tra,book.tel,book.cell,book.bir,book.pi,book.wealth,book.max,book.flag,book.id3,book.date,book.Rd,book.Rw,book.Rm,book.MRd,book.MRw,book.MRm,book.id4,book.date1,book.p,book.betaM,book.betaY,both.no, both.time, both.date, both.execution, both.buy, both.sell, both.p1, both.q1, both.p2, both.q2, both.p3, both.q3, both.p4, both.q4, both.p5, both.q5, both.p6, both.q6, both.p7, both.q7, both.p8, both.q8, both.p9, both.q9, both.p10, both.q10, both.p11, both.q11
FROM both full join book on (both.no=book.sn) and (both.date=book.odate) and (both.time=book.etime) ;
QUIT;


错误讯息
1    data both;
2    infile 'e:\ddd\012.txt';
3    input a $1-2 b $3-4 c $5-6 sno 7-14 no $15-20 time 21-26 execution 27 buy 28 sell 29 d 30 e 31 f 32 g 33 p1 34-39 q1 40-47
3  !  p2 48-53 q2 54-61 p3 62-67 q3 68-75 p4 76-81 q4 82-89 p5 90-95 q5 96-103 p6 104-109 q6 110-117 p7 118-123 q7 124-131 p8
3  ! 132-137 q8 138-145 p9 146-151 q9 152-159 p10 160-165 q10 166-173 p11 174-179 q11 180-187 date2 188-195;
4    run;
NOTE: The infile 'e:\ddd\012.txt' is:
      File Name=e:\ddd\012.txt,
      RECFM=V,LRECL=256
NOTE: 1796180 records were read from the infile 'e:\ddd\012.txt'.
      The minimum record length was 198.
      The maximum record length was 198.
NOTE: The data set WORK.BOTH has 179560 observations and 36 variables.
NOTE: DATA statement used (Total process time):
      real time           38.96
      cpu time            22.79

5
6    data book;
7    infile 'e:\abc\bbb1.txt';
8    input sn $1-6 oq 7-14 op 15-20 type $21 odate 22-29 otime 30-37 eq $38-45 ep $46-51 edate $52-59 etime $60-65 bs $66 or
8  ! $67 sax $68 age 69-70 sax1 $71 ctype $72 mtype $73 tra $74 tel $75 cell $76 bir $77-84 pi $85 wealth 86-93  max 94-101
8  ! flag $102 id3 $103-108 date 109-117  Rd 118-125 .4 Rw 126-133 .4 Rm 134-141 .4 MRd 142-149 .4 MRw 150-157 .4 MRm 158-165
8  ! .4 id4 $166-171 date1 172-179  p 180-187 .2 betaM 188-195 .4 betaY 196-203 .4;
9    if date<20100609;if sn ne ' ';
10   RUN;
NOTE: The infile 'e:\abc\bbb1.txt' is:
      File Name=e:\abc\bbb1.txt,
      RECFM=V,LRECL=256
NOTE: 317205 records were read from the infile 'e:\abc\bbb1.txt'.
      The minimum record length was 203.
      The maximum record length was 203.
NOTE: The data set WORK.BOOK has 153143 observations and 38 variables.
NOTE: DATA statement used (Total process time):
      real time           1.81 seconds
      cpu time            1.68 seconds

11
12
13   PROC SQL;
14   CREATE TABLE book2 AS
15   SELECT book.sn, book.oq, book.op, book.type, book.odate, book.otime, book.ep, book.eq, book.bs, book.or, book.sax,
15 ! book.age,book.sax1,book.ctype,book.mtype,book.tra,book.tel,book.cell,book.bir,book.pi,book.wealth,book.max,book.flag,book.
15 ! id3,book.date,book.Rd,book.Rw,book.Rm,book.MRd,book.MRw,book.MRm,book.id4,book.date1,book.p,book.betaM,book.betaY,both.no,
15 !  both.time, both.date2, both.execution, both.buy, both.sell, both.p1, both.q1, both.p2, both.q2, both.p3, both.q3,
15 ! both.p4, both.q4, both.p5, both.q5, both.p6, both.q6, both.p7, both.q7, both.p8, both.q8, both.p9, both.q9, both.p10,
15 ! both.q10, both.p11, both.q11
16   FROM both full join book on (book.sn=both.no) and (book.odate=both.date2) and (book.etime=both.time) ;
ERROR: Expression using equals (=) has components that are of different data types.
17   QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.14 seconds
      cpu time            0.00 seconds
18
19
20   
21   data book3;
22   set book2;
ERROR: File WORK.BOOK2.DATA does not exist.
23   file 'e:\ddd\820.txt';
24   put  sn $1-6 oq 7-14 op 15-20 type $21 odate 22-29 otime 30-37 eq 38-45 ep 46-51 bs $52 or $53 six $54 age $55-56 sax1 $57
24 !  ctype $58 mtype $59 tra $60 tel $61 cell $62 bir $63-70 pi $71 wealth 72-79 max 80-87 flag $88 id3 $89-94 date 95-102  Rd
24 !  103-110 .4 Rw 111-118 .4 Rm 119-126 .4 MRd 127-134 .4 MRw 135-142 .4 MRm 143-150 .4 id4 $151-156 date1 157-164 p 165-170
24 ! .2 betaM 171-178 .4 betaY 179-186 .4  no $187-192 time 193-200 date2 201-208 execution $209 buy $210 sell $211 p1 212-217
24 ! q1 218-225 p2 226-231 q2 232-239 p3 240-245 q3 246-253 p4 254-259 q4 260-267 p5 268-273 q5 274-281 p6 282-287 q6 288-295
24 ! p7 296-301 q7 302-309 p8 310-315 q8 316-323 p9 324-329 q9 330-337 p10 338-343 q10 344-351 p11 352-357 q11 358-365;
25   run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.BOOK3 may be incomplete.  When this step was stopped there were 0 observations and 64 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2010-8-21 08:02:36 | 只看该作者

Re: 语法错误?

[quote:3517wid9]ERROR: Expression using equals (=) has components that are of different data types[/quote:3517wid9]
FROM both full join book on (both.no=book.sn) and (both.date=book.odate) and (both.time=book.etime)

data set book, etime: character variable
input ... sn $1-6 ... odate 22-29 ... [b:3517wid9][color=#FF0000:3517wid9]etime $60-65 [/color:3517wid9][/b:3517wid9] ...;

data set both, time: numeric variable
input ... no $15-20 ... [b:3517wid9][color=#FF0000:3517wid9]time 21-26 [/color:3517wid9][/b:3517wid9]... date 188-195;
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2010-8-21 13:38:56 | 只看该作者

Re: 语法错误?

hopewell大侠看的好仔细.... <!-- s:shock: --><img src="{SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked" /><!-- s:shock: -->
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
地板
 楼主| 发表于 2010-8-23 23:14:23 | 只看该作者

Re: 语法错误?

thank you !
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2026-2-3 23:49 , Processed in 0.069654 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表