楼主: luyoung
4277 3

[问答] proc sql调用宏变量 [推广有奖]

  • 2关注
  • 0粉丝

已卖:157份资源

本科生

52%

还不是VIP/贵宾

-

威望
0
论坛币
1066 个
通用积分
35.7096
学术水平
0 点
热心指数
5 点
信用等级
0 点
经验
847 点
帖子
35
精华
0
在线时间
122 小时
注册时间
2016-1-21
最后登录
2025-4-10

楼主
luyoung 发表于 2018-1-30 17:42:17 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
  1. proc sql noprint;
  2. select contract_no into :contract_no separated by '","'
  3.         from aaa;
  4. quit;

  5. proc sql;
  6. create table bbb as
  7.         select a.contract_no,
  8.         from database.ccc a
  9.         where a.contract_no in ("&contract_no.");
  10. quit;
复制代码
提取远程Oracle数据库内ccc表内命中&contract_no.的信息,因特殊原因必须使用宏变量降低跑数据时间,请问如何修改才能跑通?
二维码

扫码加我 拉你入群

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

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

关键词:proc sql ROC sql contract separate 宏变量

沙发
xiami2000 在职认证  发表于 2018-1-31 12:14:49
Is contract_no numeric or character ?
If it is numeric:
    proc sql ;
      select distinct contract_no into : contract_no separated by ','
      from aaa;
    quit;


If it is character:
    proc sql ;
      select distinct "'"||strip(contract_no)||"'" into : contract_no separated by ','
      from aaa;
    quit;


GOOD LUCK

藤椅
luyoung 发表于 2018-2-2 11:27:41
xiami2000 发表于 2018-1-31 12:14
Is contract_no numeric or character ?
If it is numeric:
    proc sql ;
It is character type variable. Thank you so much.Pity,micro variable 'contract_no' is unavilable in the 'proc sql' step connect to oracle. Like:
  1. proc sql;
  2. connect to oracle as oracledata(user=* password=** path=***);
  3. create table ccc as
  4.         select * from connection to oracledata(
  5.                 select a.contract_no
  6.                 from database.bbb a
  7.                 where a.contract_no in (&contract_no.)
  8.         );
  9. disconnect from oracledata ;
  10. quit;
复制代码


板凳
xiami2000 在职认证  发表于 2018-2-6 02:33:00
Did you create macro varible 'contract_no' as ??
   proc sql ;
       select distinct "'"||strip(contract_no)||"'" into : contract_no separated by ','
       from aaa;
     quit;
If so, please use %put &contract_no to display here.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-5 01:41