sql - 如何在proc sql的where子句中使用宏变量
问题描述
例如,我有:
%let state_exclude = Michigan Maine Minnesota;
proq sql;
create table States
select state
from geography_dim as geo
where geo.country="US" and geo.state ~= "&state_exclude"
quit;
它返回零行,我认为这是因为我在那里使用宏变量但我不知道如何修复它
解决方案
我不是美国人,难道是“Michigan Maine Minnesota”三个独立的地方?如果是这样,您应该使用in
operator 而不是=
. 例如:
%let state_exclude = "Michigan" "Maine" "Minnesota";
proq sql;
create table States as
select state from geography_dim
where country="US" and state not in (&state_exclude);
quit;
推荐阅读
- docker - 在 docker 上部署时如何更改 Tomcat 中的基本 URL
- docker - 部署失败'
Dockerfile:Dockerfile' - python-3.x - Django 静态 style.css 样式
- excel - 如何在UiPath RPA中匹配系统数据表和excel之间的同一列
- arrays - json对象到带有if else的列
- filter - 在 LDAP 过滤器中添加以 ABC 开头的用户到系统
- bash - echo 行没有正确重定向到 bash 脚本?
- google-sheets - 计算值而不必指定每个值
- quantlib - Quantlib:可赎回和可回售期权的债券
- python - 从文件中读取数字时出现 KeyError