Help using Base SAS procedures

%Let Equal a value from a Table

Not applicable
Posts: 1

%Let Equal a value from a Table


I am new to the forum and I am not sure if I am posting in the correct place.

I would like to assign a value to a name and then use that in other procedures, say

%Let = select Profit from MyTable where Month = 'Feb'

So then when I am working in another table I can use this in a datastep for example.

I am not sure if it is a stupid question?

Frequent Contributor
Posts: 131

Re: %Let Equal a value from a Table


I think you should have posted your topic in the following discussion forum:
SAS Macro Facility, Data Step and SAS Language Elements

To create a macro-variable from the result of a SQL query, you have to use the following proc sql:

proc sql;
select Profit
into Smiley Tonguerofit /* You can give the name you want but have to make sure */
from MyTable /* that your SQL query will only return 1 value. */
where Month = 'Feb';

Have a look to the following link in order to get more details about the possibilities you have to generate macro-variables with PROC SQL:

Ask a Question
Discussion stats
  • 1 reply
  • 1 like
  • 2 in conversation