在 PROC SQL (SAS) 中声明变量

dim*_*mos 4 sas proc-sql

我正在尝试在 PROC SQL 上使用一个变量,但我无法通过互联网找到正确的方法。我只想在 PROC SQL 上应用以下 T-SQL 代码:

 declare @example as int;
set @example=2;
select * from {table} where {column}=@example;
go
Run Code Online (Sandbox Code Playgroud)

如何在 PROC SQL 上应用此代码?

Ree*_*eza 5

SAS SQL 的转换是使用宏变量,代码看起来非常相似,但需要将其包装在 PROC SQL 块中。

%let example=2;

proc sql;
select *
from table
where variable=&example;
quit;
Run Code Online (Sandbox Code Playgroud)

编辑:我对宏变量的原始引用不正确,在 SAS 中使用与号而不是 @ 符号。