BookmarkSubscribeRSS Feed
LXG
Calcite | Level 5 LXG
Calcite | Level 5

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

9 REPLIES 9
Reeza
Super User

Same results in SAS 9.2

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

Tom
Super User Tom
Super User

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

LXG
Calcite | Level 5 LXG
Calcite | Level 5

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.

Reeza
Super User

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;

LXG
Calcite | Level 5 LXG
Calcite | Level 5

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.

Reeza
Super User

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.

joejw84
Calcite | Level 5

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.

Cynthia_sas
SAS Super 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

joejw84
Calcite | Level 5

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

Joe

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register 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.

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
  • 9 replies
  • 4968 views
  • 0 likes
  • 5 in conversation