Help using Base SAS procedures

%Let Equal a value from a Table

Reply
N/A
Posts: 1

%Let Equal a value from a Table

Hello

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?

Thanks
Frequent Contributor
Posts: 127

Re: %Let Equal a value from a Table

Hello,

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';
quit;

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:
http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/a001360983.htm

Regards,
Florent
Ask a Question
Discussion stats
  • 1 reply
  • 135 views
  • 0 likes
  • 2 in conversation