SAS中文论坛

标题: 例子:宏变量的拼接和引用 [打印本页]

作者: shiyiming    时间: 2003-12-19 09:07
标题: 例子:宏变量的拼接和引用
例子:
程序是这样的:
%let zd001=coilno as m_no,
           FAANFA204,
           FAANFA407_1;
           
%let zd002=coilno as m_no,
           FASLF006;
                  
%let zd003=coilno as m_no,
           MCC1F025;
  中间略……      
%let zd009=coilno as m_no,
           MFT1F031_1,
           MFT1F031_2,
           MFT1F031_3,
           MFT1F031_4,
           J;

%macro cre00(i);
%do j=1 %to &i;
proc sql;
    create table tch100&j
    as select &zd00&j from suipc000&j where coilno in (select coilno from tmp0);
quit;
%end;
%mend;
%cre00(9);

这个程序是错误的,&zd00&j的意思取zd00的值与j的值拼在一起。
SAS出现如下出错信息:
NOTE: Line generated by the invoked macro "CRE00".
1 &zd00&j from ipc_1580.suipc000&j where
-
22
1 ! coilno in (select coilno from tmp0); quit;
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
a numeric constant, a datetime constant, a missing value, INPUT, PUT, USER.
作者: shiyiming    时间: 2003-12-19 09:32
现在改成这样了,还是错的

%macro cre00(zd,i);
%do j=1 %to &i;
proc sql;
    create table tch100&j
    as select &zd&j from ipc_1580.suipc000&j where coilno in (select coilno from tmp0);
quit;
%end;
%mend;
%cre00(zd00,9);


出错信息:
ERROR: The following columns were not found in the contributing tables: zd001.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used:
      real time           0.01 seconds
      cpu time            0.01 seconds



ERROR: The following columns were not found in the contributing tables: zd002.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used:
      real time           0.01 seconds
      cpu time            0.01 seconds
作者: shiyiming    时间: 2003-12-19 09:50
解决了!!

%macro cre00(zd,i);
%do j=1 %to &i;
proc sql;
    create table tch100&j
    as select &&&zd&j from ipc_1580.suipc000&j where coilno in (select coilno from tmp0);
quit;
%end;
%mend;
%cre00(zd00,9);
作者: shiyiming    时间: 2003-12-19 09:51
你们这里解决问题的速度,太慢了!应该有个常驻班主才是呀
作者: shiyiming    时间: 2003-12-19 09:53
我一个人在这里自言自语,真没意思!!
作者: shiyiming    时间: 2003-12-19 11:08
回应一下,免得apan太寂寞!!

<!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->  <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->  <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->  <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->
作者: shiyiming    时间: 2003-12-19 13:19
谢谢!




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