首页 > 解决方案 > Proc Sql Select Into 正在创建一个我无法调用的临时变量

问题描述

我正在尝试使用 proc sql select into 创建一个变量,然后尝试稍后调用。这个变量是平均价格(BlockPrice)。

proc sql;
   create table Block_Price_Calc as 
   select mean(Price) Into : BlockPrice
from Data1
Where As_Of_Date >= '31MAR2015'd and As_Of_Date < '07APR2015'd;
quit;

%put &BlockPrice;

proc sql;
 create table Want as 
 select *,
     (&BlockPrice) as Block
 from Data2;
quit;

变量 BlockPrice 未被识别,它似乎被存储为临时变量。有什么想法吗?

标签: sqlsasprocselect-into

解决方案


INTO子句不能在 CREATE TABLE 语句中使用。

proc sql; 
   select mean(Price) Into : BlockPrice
   from Data1
   Where As_Of_Date >= '31MAR2015'd and As_Of_Date < '07APR2015'd;
quit;

推荐阅读