楼主: lss5918
2933 6

求看看这个IF条件怎么不生效 [推广有奖]

  • 0关注
  • 0粉丝

已卖:322份资源

初中生

90%

还不是VIP/贵宾

-

威望
0
论坛币
441 个
通用积分
1.6076
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
613 点
帖子
14
精华
0
在线时间
20 小时
注册时间
2010-3-25
最后登录
2014-12-16

楼主
lss5918 发表于 2014-7-18 12:25:55 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如下宏中,为什么%if &file=='sDET'成立却不执行THEN后面的,反而跳到去执行ELSE后面的语句,程序也没有错误,求大神指点!!!!!!

还没有解决,继续等待大神的帮助!!!!

libname DET_DATA 'C:\SAS DATA\lib\det';
option mprint;
%macro downdata(file,start,end,pro);/*mcw=,ow=,ser=)*/
proc sql;
connect to odbc (datasrc=qedb user=xxxx password=1234);
%if &file=='sDET' %then create table  DET_DATA.&pro as select *
from connection to odbc(select * from DBUSER.DATA_GTSD_&pro
where TST_DATE_TIME >=timestamp(current date -&end days,'00.00.00') and TST_DATE_TIME <=timestamp(current date -&start days,'24.00.00'));
%else create table  DET_DATA.&pro as select *
from connection to odbc(select * from DBUSER.DATA_GTMG_&pro
where TST_DATE_TIME >=timestamp(current date -&end days,'00.00.00') and TST_DATE_TIME <=timestamp(current date -&start days,'24.00.00'));;

disconnect from odbc;
quit;
%mend;
%downdata(sDET,0,2,KCG)



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:connection proc sql password Connect CURRENT password current create option where

沙发
bridge1989 发表于 2014-7-18 12:56:08
把if和then之前的%去掉,因为不是来执行宏程序

藤椅
zhanglianbo35 发表于 2014-7-18 13:04:51
%else 前面少了一个分号

板凳
lss5918 发表于 2014-7-18 13:26:17
谢谢楼上2位,不过这样改程序反而报错了。
回3楼,else 前再加;的话,也提示错误ERROR: There is no matching %IF statement for the %ELSE.
                                                        ERROR: A dummy macro will be compiled.

回2楼,不要%号提示:Statement is not valid or it is used out of proper order.

1                                                                                     if
                                                                                      --
                                                                                      180
1  ! &file=='sDET' then create table  DET_DATA.&pro as select *     from connection to
1  ! odbc(select * from DBUSER.DATA_GTSD_&pro     where TST_DATE_TIME >=timestamp(current
1  ! date
MPRINT(DOWNDATA):   if sDET=='sDET' then create table DET_DATA.KCG as select * from
connection to odbc(select * from DBUSER.DATA_GTSD_KCG where TST_DATE_TIME
>=timestamp(current date -2 days,'00.00.00') and TST_DATE_TIME <=timestamp(current date -0
days,'24.00.00'));
ERROR 180-322: Statement is not valid or it is used out of proper order.

报纸
lss5918 发表于 2014-7-18 14:06:40
没大神指教下吗?等待中

地板
jingju11 发表于 2014-7-18 21:22:48
lss5918 发表于 2014-7-18 14:06
没大神指教下吗?等待中
&file = sDET
JingJu

7
lss5918 发表于 2014-7-21 18:40:18
谢谢,是的,不要引号!

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 14:56