BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
dwaldo
Calcite | Level 5

I have a user-defined format (created by cntlin= from a SAS dataset); I want to add values to the format and turn it into a multilabel format.

 

I am unsure how to do this ... .

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

SAS Help Center: Results: PROC FORMAT

 


@dwaldo wrote:

So, HLO=SM is what tells SAS this is a multi-label format? Not the most obvious solution I have ever encountered, but it does the trick -- thanks!

By the way -- where is this (and the other fields in that cntlout file) documented? Even The Google was perplexed


I think this is a really good discussion if really good.

Multiple Facts about Multilabel Formats

 

View solution in original post

6 REPLIES 6
sbxkoenk
SAS Super FREQ

In this blog you find an example that creates a multilabel format using the CNTLIN= option in PROC FORMAT.

Creating and Using Multilabel Formats

https://blogs.sas.com/content/sgf/2016/12/16/creating-and-using-multilabel-formats/

 

Also ... in this NESUG 2008 conference paper, you find MULTILABEL FORMATS WITH CNTLIN DATASETS.
Multiple Facts about Multilabel Formats
Gwen D. Babcock, New York State Department of Health, Troy, NY
https://lexjansen.com/nesug/nesug08/cc/cc14.pdf

 

Or ... go here:
creating multi labels using proc format cntlin

https://communities.sas.com/t5/New-SAS-User/creating-multi-labels-using-proc-format-cntlin/td-p/5953...

 

Instead of using a CNTLIN= dataset, you can also generate your PROC FORMAT code dynamically from a dataset. This is called data-driven dynamic code generation. You use a datastep with a FILE statement and PUT statements and once the SAS program is created you %INCLUDE it.

 

BR, Koen

Tom
Super User Tom
Super User

Figure out how SAS stores the value for a MLF in a CNTLIN= dataset by making one by code and looking at the dataset generated by the CNTLOUT= option.

proc format cntlout=formats;

value myfmt (multilabel)
  1 = "One"
  2 = "Two"
  3 = "Three"
  4 = "Four"
  5 = "Five"
  1,3,5 = "Odd"
  2,4 = "Even"
  1-5 = "1-5"
;

run;

proc print data=formats;
  var fmtname type start end label hlo sexcl eexcl ;
run;

Screenshot 2026-04-08 at 12.38.59 PM.png

So basically just add the extra observations you need and set the HLO variable 'SM'.

data_null__
Jade | Level 19

I notice that SAS has given the MYFMT format the NOTSORTED attribute in the CNTLOUT data set, HLO='SM' even though you did not specify NOTSORTED in the VALUE statement options list.  

I did not expect that output.

 


@Tom wrote:

Figure out how SAS stores the value for a MLF in a CNTLIN= dataset by making one by code and looking at the dataset generated by the CNTLOUT= option.

proc format cntlout=formats;

value myfmt (multilabel)
  1 = "One"
  2 = "Two"
  3 = "Three"
  4 = "Four"
  5 = "Five"
  1,3,5 = "Odd"
  2,4 = "Even"
  1-5 = "1-5"
;

run;

proc print data=formats;
  var fmtname type start end label hlo sexcl eexcl ;
run;

Screenshot 2026-04-08 at 12.38.59 PM.png

So basically just add the extra observations you need and set the HLO variable 'SM'.





 

 

 

dwaldo
Calcite | Level 5

So, HLO=SM is what tells SAS this is a multi-label format? Not the most obvious solution I have ever encountered, but it does the trick -- thanks!

By the way -- where is this (and the other fields in that cntlout file) documented? Even The Google was perplexed

data_null__
Jade | Level 19

SAS Help Center: Results: PROC FORMAT

 


@dwaldo wrote:

So, HLO=SM is what tells SAS this is a multi-label format? Not the most obvious solution I have ever encountered, but it does the trick -- thanks!

By the way -- where is this (and the other fields in that cntlout file) documented? Even The Google was perplexed


I think this is a really good discussion if really good.

Multiple Facts about Multilabel Formats

 

Tom
Super User Tom
Super User

@data_null__ wrote:

I notice that SAS has given the MYFMT format the NOTSORTED attribute in the CNTLOUT data set, HLO='SM' even though you did not specify NOTSORTED in the VALUE statement options list.  

I did not expect that output.

...


I think that it what the paper you cited means when it talks about sorting.

Essentially when you using the LABEL statement of PROC FORMAT without the NOTSORTED option for a multilabel format it sorts by the START value and then generates the control dataset in that order and set the 'S' tag of the HLO variable to preserve it.

 

You can see it by replicating the AGE format from that paper.

proc format cntlout=formats;
value age (multilabel)
19-120='Adults'
1-18='Children'
1-4='Preschool'
;
value ages (multilabel notsorted)
19-120='Adults'
1-18='Children'
1-4='Preschool'
;
run;

data compare;
  N+1;
  set formats(where=(fmtname='AGE') rename=(start=AGE_START end=AGE_END label=AGE_LABEL));
  set formats(where=(fmtname='AGES') rename=(start=AGES_START end=AGES_END label=AGES_LABEL));
run;

proc print;
var N age: ;
run;

 Screenshot 2026-04-08 at 5.49.28 PM.png

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 521 views
  • 1 like
  • 4 in conversation