Help using Base SAS procedures

Percent sign (%) in variable label is doubled (%%) by PROC FREQ

Reply
New Contributor LXG
New Contributor
Posts: 3

Percent sign (%) in variable label is doubled (%%) by PROC FREQ

I got a problem when using PROC FREQ, can anyone help? Thanks in advance.

There is a percent sign (%) in the label of a variable - At least 30% increase, by using PROC FREQ for the frequency table i got result "At least 30%% increase" in the output window, present sign is doubled.

I'm using SAS V 9.3 TS1M0 on AIX 6.1 (AIX 64).

Try below codes:

data test;

   label x="Category" y="Percent (%)";

   do x=1,2;

      do y=20,30;

         output;

      end;

   end;

run;

proc freq data=test;

   table x*y;

run;

Here is the result:

                                                     The SAS System

                                                   The FREQ Procedure

                                                    Table of x by y

                                          x(Category)     y(Percent (%%))

                                          Frequency_

                                          Percent  _

                                          Row Pct  _

                                          Col Pct  _      20_      30_  Total

                                          ____________________________

                                                1 _      1 _      1 _      2

                                                   _  25.00 _  25.00 _  50.00

                                                   _  50.00 _  50.00 _

                                                   _  50.00 _  50.00 _

                                          ____________________________

                                                 2 _      1 _      1 _      2

                                                   _  25.00 _  25.00 _  50.00

                                                   _  50.00 _  50.00 _

                                                   _  50.00 _  50.00 _

                                          ____________________________

                                          Total           2        2        4

                                                      50.00    50.00   100.00

Super User
Posts: 19,792

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

Same results in SAS 9.2

Are you looking for a work around or reporting a bug?

Super User
Super User
Posts: 7,046

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

Seems to have started in 9.2.  I do not see that in 6.12, 8.2 or 9.1.3 versions of SAS.

New Contributor LXG
New Contributor
Posts: 3

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

i'm trying to eliminate this issue, as this kind of results is a part of my analysis report, %% is not acceptable. Otherwise, i'll have to avoid using % for the variable label.

I'm thinking maybe i can modify the template for PROC FREQ, but i'm not familiar with it at present.

Super User
Posts: 19,792

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

You could also use proc tabulate instead, generally cleaner results anyways.

data test;

   label x="Category" y="Percent (%)"

   do x=1,2;

      do y=20,30;

         output;

      end;

   end;

run;

 

proc tabulate data=test;

  class x y;

   table (x all='All X')*(n rowpctn colpctn), (y all='All Y');

run;

New Contributor LXG
New Contributor
Posts: 3

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

sorry, i should provide more info. i have to use FREQ for an inferential test, the p-value is also required, e.g, table x*y/ CHISQ, the frequency table is a reference for the statistical results.

Super User
Posts: 19,792

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

See here then:

SAS(R) 9.2 Output Delivery System: User's Guide

I highly format my output for typical statistical reports usually. If you wanted, you could capture the p-value and merge it into the results and then report it back out.

Regardless, I would report it to tech support, it definitely seems like a bug.

New Contributor
Posts: 2

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

Just been grappling with this very problem and found a way around it using the unicode representation for % rather than the character. You need to create an escape character, I used the '~', but it could be another character.

ods escapechar = "~";

data test; 

  label x= "Category" y= "Percent (~{unicode 0025})"; * Unicode 0025 is the code for '%';

   do x=1,2; 

      do y=20,30; 

         output; 

      end

   end

run

  

proc freq data=test; 

   table x*y; 

run; 

This will only work with the ODS output, and I've only tried it 9.3.

SAS Super FREQ
Posts: 8,865

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

Hi:

  I still think the OP should open a track with Tech Support. I found 2 references to "doubling" -- one in a solution for & and another for %, so I think this person has stumbled on some loophole that causes doubling that should have a track opened because the situation of %% that the OP found is different from what is described in this Tech Support note:

18708 - Dynamic column headers containing a percent sign (%) might generateunexpected results when u...

and, other doubling behavior:

49188 - Double ampersands might appear in labels

cynthia

New Contributor
Posts: 2

Re: Percent sign (%) in variable label is doubled (%%) by PROC FREQ

Posted in reply to Cynthia_sas

Agreed. It shouldn't need a work-around for something so simple.

Joe

Ask a Question
Discussion stats
  • 9 replies
  • 1363 views
  • 0 likes
  • 5 in conversation