SAS中文论坛

标题: 怎么和sas帮助文档有矛盾? [打印本页]

作者: shiyiming    时间: 2006-6-28 18:42
标题: 怎么和sas帮助文档有矛盾?
SELECT;   
WHEN ( exp1 ) stmt1;
  stmt2;
WHEN ( exp2 ) stmt3;
  stmt4;
END;
这是sas文档说when语句可以支持多语句情形不必用do-end模块,但是我的程序就老是跑不出来,如果去掉其中的一个k=x或r=x+1又没有问题,还请高手指点,程序如下:
data a;
input x;
cards;
1
2
3
3
6
4
5
;
run;
data b(drop=x) ;
set a;
select;
when(x<=4)
k=x;
r=x+1;
when(x>=5)
w=x;
end;
run;
proc print data=b;run;
作者: shiyiming    时间: 2006-6-28 22:13
标题: replay
The syntax should be:

SELECT;
WHEN ( exp1 ) stmt1;  /* only one statement block */
WHEN ( exp2 ) stmt3;
END;

or

SELECT;
WHEN ( exp1 )
  do;                    /* multi-statements in DO...END block */
    stmt1;
    stmt2;
  end;
WHEN ( exp2 )
    do;
       stmt3;
       stmt4;
     end;
END;
作者: shiyiming    时间: 2006-6-29 09:59
标题: 不是这样得
但是sas文档里面得语法就是这样写的啊,他就是强调可以不用do-end来实现多语句得功能啊,这位仁兄可能没看清楚我得帖子,不信你可以在sas帮助文档里看一下这方面得描述。不过还是thanks all the same。
作者: shiyiming    时间: 2006-6-29 16:19
标题: to wzfgyd
为了你美好的前途,我也只好豪赌一下对你进行解释,我没看文档,不过我猜想,人家文档的意思是,子WHEN语句中的语句可以不用DO END包括起来,不过如果最后一个语句也不用END包括,那程序执行到哪一句话算是最后一个WHEN语句块的结束呢?
你以为SAS有那么聪明吗?
作者: shiyiming    时间: 2006-6-29 21:36
标题: RE:
There is not found about SELECT statement as wzfgyd 写到
[code:c3ec1]
sas文档里面得语法就是这样写的啊,他就是强调可以不用do-end来实现多语句得功能
[/code:c3ec1]

I've checked it from SASv8.2 and v9.1 in English version.

wzfgyd, I'd like to see the description from your SAS help if you can copy it  to here.
作者: shiyiming    时间: 2006-6-29 23:49
标题: sas文档关于when的描述
The WHEN and OTHERWISE statements allow more than one target statement. That is, DO groups are not necessary for multiple statement WHENs. For example in PROC MODEL, the following syntax is valid:



   select;
      when(exp1)  
         stmt1;
         stmt2;
      when(exp2)  
         stmt3;
         stmt4;
   end;
作者: shiyiming    时间: 2006-7-1 00:35
标题: RE:
I think that is a special note to say the differences between SLECT..WHEN..END statement in the NLP,CALIS, GENMOD, and MODEL procedures (refer to the SAS/ETS) and in the DATA step (refer to SAS/Base).  Other words, below syntax is valid in the procedures mentioned above, but in DATA STEP.
[code:ebe82]
SELECT;
  WHEN ( exp1 ) stmt1;
                        stmt2;
  WHEN ( exp2 ) stmt3;
                stmt4;
END;
[/code:ebe82]




欢迎光临 SAS中文论坛 (http://mysas.net/forum/) Powered by Discuz! X3.2