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 !
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1878 views
  • 0 likes
  • 2 in conversation