簡體   English   中英

如何在 proc sql 的 where 子句中使用宏變量

[英]How to use a macro variable in a where clause in proc sql

例如,我有:

%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;

它返回零行,我認為這是因為我在那里使用宏變量但我不知道如何修復它

我不是美國人,是“密歇根緬因明尼蘇達”三個獨立的地方嗎? 如果是這樣,您應該使用in運算符而不是= 例如:

%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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM