ldan
ldan

Reputation: 41

Proc Sql Select Into Is Creating a Temporary Variable that I can't Call

I am trying to use proc sql select into to create a variable that I then try to call later. This variable is the average price (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;

The variable BlockPrice is not being recognized and it seems like it is being stored as a temporary variable. Any thoughts?

Upvotes: 1

Views: 375

Answers (1)

Llex
Llex

Reputation: 1770

An INTO clause cannot be used in a CREATE TABLE statement.

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

Upvotes: 1

Related Questions