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

I'm running PROC MEANS on a labeled variable, that has a % in the label.  The output (both listing and ODS HTML) shows two percent signs.

 

proc means data=sashelp.class ;
  var age ;
  label age='My % label with %' ;
run ;

Returns:

                        The MEANS Procedure

             Analysis Variable : Age My %% label with %%

  N            Mean         Std Dev         Minimum         Maximum
 19      13.3157895       1.4926722      11.0000000      16.0000000
 

Any particular reason this happens, or way to avoid it?  PROC PRINT and PROC FREQ don't double the percent signs.

 

Above is from 9.4M4 on Win10.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

Tech support confirmed it is a known issue, and suggested the unicode workaround.  I recommended they add a problem note to document this (or expand the current note since the problem is not limited to FILE PRINT ODS).

 

They sent:

ods escapechar='^';
ods listing close;
ods pdf file='ctest.pdf';
 
proc means data=sashelp.class ;
  var age ;
  label age='My ^{unicode 0025} label with ^{unicode 0025}' ;
run ;


proc freq data=sashelp.class;
  tables name*sex ;
  label name='Name with ^{unicode 0025}' ;
  label sex='sex with ^{unicode 0025}' ;
run ;

ods pdf close;
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

View solution in original post

5 REPLIES 5
FreelanceReinh
Jade | Level 19

Hi @Quentin,

 

This 2013/2014 thread suggests that it started with SAS 9.2 and this is also the first version where I saw it in PROC FREQ cross-tabulations, but not in univariate tables (!), and later in PROC MEANS. My attempt to write the percent sign as %sysfunc(byte(37)) failed. However, in the old thread a user joejw84 stated he had more luck using a unicode representation for ODS output, which I haven't tried yet.

Quentin
Super User

Wow, I'm shocked this bug could have survived since 9.2.  I'll send it in to tech support, just in case the OP of that thread never did.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
ballardw
Super User

This apparently is coming from the BASE.SUMMARY template in SASHELP.TMPLMST and the way the dynamic variable for labels is treated.

 

However I can't find anything in Proc Template documentation (which I hate digging through) for dynamic variables, which the Label is, for why this might happen as there is no actual manipulation of the label variable in the template.

 

You might be able to create a custom version of the template and change the code for the header to resemble the code for the LCLM and UCLM headers which do display a single %.

 

Or send the result to data set and use a Title statement to say the same thing with proc print.

 

Quentin
Super User

Thanks @ballardw.  In the older thread Cynthia Z pointed out this support note, http://support.sas.com/kb/18/708.html, also about % signs in labels being doubled in dynamic column headers, but the note suggests it's more limited scope.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
Quentin
Super User

Tech support confirmed it is a known issue, and suggested the unicode workaround.  I recommended they add a problem note to document this (or expand the current note since the problem is not limited to FILE PRINT ODS).

 

They sent:

ods escapechar='^';
ods listing close;
ods pdf file='ctest.pdf';
 
proc means data=sashelp.class ;
  var age ;
  label age='My ^{unicode 0025} label with ^{unicode 0025}' ;
run ;


proc freq data=sashelp.class;
  tables name*sex ;
  label name='Name with ^{unicode 0025}' ;
  label sex='sex with ^{unicode 0025}' ;
run ;

ods pdf close;
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 5 replies
  • 1393 views
  • 3 likes
  • 3 in conversation