BookmarkSubscribeRSS Feed
AldousA
Calcite | Level 5
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
1 REPLY 1
Florent
Quartz | Level 8
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 :Profit /* 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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 4721 views
  • 1 like
  • 2 in conversation