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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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