如何在procsql的where子句中使用宏变量

zz2j4svz  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(460)

例如,我有:

  1. %let state_exclude = Michigan Maine Minnesota;
  2. proq sql;
  3. create table States
  4. select state
  5. from geography_dim as geo
  6. where geo.country="US" and geo.state ~= "&state_exclude"
  7. quit;

它返回零行,我想这是因为我在那里如何使用宏变量,但我不知道如何修复它

sr4lhrrt

sr4lhrrt1#

我不是美国人,是“密歇根州缅因州明尼苏达州”三个独立的地方吗?如果是这样,你应该使用 in 操作员而不是 = . 例如:

  1. %let state_exclude = "Michigan" "Maine" "Minnesota";
  2. proq sql;
  3. create table States as
  4. select state from geography_dim
  5. where country="US" and state not in (&state_exclude);
  6. quit;

相关问题