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 !

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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