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
Same results in SAS 9.2
Are you looking for a work around or reporting a bug?
Seems to have started in 9.2. I do not see that in 6.12, 8.2 or 9.1.3 versions of SAS.
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.
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;
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.
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.
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.
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:
and, other doubling behavior:
49188 - Double ampersands might appear in labels
cynthia
Agreed. It shouldn't need a work-around for something so simple.
Joe
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!
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.