BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phil_NZ
Barite | Level 11

Hi all SAS Users,

I want to ask your experience about how to set the title quickly for the output of a proc mean. Because sometimes I run a lot of proc means and I need to know the name of the dataset it is about.

 

So, normally, I use the title statement:

proc means data=have;
title "have";
run;

Could you please let me know if there is any way to set the title for the output of proc means without typing the statement title and else?

 

Warm regards.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

@Phil_NZ  - You could enhance the macro to do different statistics by adding a stats parameter.

%macro Means (dataset = 
              ,stats_list = );

proc means data= &dataset &stats_list;
title "&dataset";
run;

%mend Means;

%Means (dataset = Have
        ,stats_list = mean min max);
%Means (dataset = Have2
        ,stats_list = n min max);

View solution in original post

4 REPLIES 4
SASKiwi
PROC Star
%macro Means (dataset = );

proc means data= &dataset;
title "&dataset";
run;

%mend Means;

%Means (dataset = Have);
Phil_NZ
Barite | Level 11

Hi @SASKiwi 

Thank you very much for the macro, but there would be some proc means I used different options (in one PROC MEAN I may use mean, max, nmiss, n, in another PROC MEAN I may use kurt  std  max min, and in some PROC MEAN, I may just need one or two specific variables)

So the macro cannot work in these case. But it is a very nice macro. I may adjust all the proc mean together to run the macro if there is no other solution.

 

Many thanks and warm regards.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
SASKiwi
PROC Star

@Phil_NZ  - You could enhance the macro to do different statistics by adding a stats parameter.

%macro Means (dataset = 
              ,stats_list = );

proc means data= &dataset &stats_list;
title "&dataset";
run;

%mend Means;

%Means (dataset = Have
        ,stats_list = mean min max);
%Means (dataset = Have2
        ,stats_list = n min max);

Phil_NZ
Barite | Level 11

Hi @SASKiwi 

 

Thank you for your insightful suggestion!

 

Warmest regards

 

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 3238 views
  • 3 likes
  • 2 in conversation