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

As a simple example to learn Multilabel formats, let's suppose I want to use SASHELP.CLASS to determine average height amongst 11-13 year olds, and amongst 12-14 year olds;

proc format;
    value agefmt (multilabel) 11-13='11-13' 12-14='12-14';
run;
proc summary data=sashelp.class(where=(age<=14));
	var height;
	class age;
	output out=_stats_ mean=;
	format age agefmt.;
run;

Works as expected. Now suppose I also want to have one more average computed by the same PROC SUMMARY, where I want the mean of just 13 year olds.

 

proc format;
    value agefmt (multilabel) 11-13='11-13' 12-14='12-14' 13-13='13';
run;
proc summary data=sashelp.class(where=(age<=14));
	var height;
	class age;
	output out=_stats_ mean=;
	format age agefmt.;
run;

This does not produce an average for just 13 year olds.

 

Am I doing something wrong? Or am I misunderstanding the functionality of MULTILABEL formats? (Yes, I know I can get this from two PROC SUMMARY calls, but I really would like to understand the MULTILABEL format)

--
Paige Miller
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User
You need to tell PROC SUMMARY you want to treat the formats as multi label by adding the MLF option to the CLASS statement.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User
You need to tell PROC SUMMARY you want to treat the formats as multi label by adding the MLF option to the CLASS statement.
PaigeMiller
Diamond | Level 26

Ah, that seems to do it. It sure would be nice if the PROC FORMAT documentation mentioned that, but it doesn't. Thanks, @Tom 

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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