BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,
I would like to store the mean of a data set variable in a variable such that I could use the value without writing it myself each time I need it.
Is this possible ?
If yes, how can I proceed ?

Thank you in advance
2 REPLIES 2
DanielSantos
Barite | Level 11
Not sure of what you need, but maybe storing the desired value into a SAS macro variable may solve your problem.

proc sql noprint;
select mean(VALUE) into :MEAN_VALUE from DATA;
quit;

the into: statement will load a value into a SAS macro variable through SQL.

See the online doc here:
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a000543554.htm

From there, you just need to reference the SAS macro variable in your program, then at runtime this will be substituted by the actual value loaded previously.

for example:
data _null_;
put "Mean value is: &MEAN_VALUE";

/* or */

MEAN=&MEAN_VALUE;
put MEAN=;
run;

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
deleted_user
Not applicable
Yes it was what I wanted to do, your solution worked perfectly.
Many thanks from France !

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 1303 views
  • 0 likes
  • 2 in conversation