Hello
In following code i am trying to change format of one way proc freq.
For example :
For Make=Hummer frequency=1 and Relative Frequency should be 1/428=0.23%
But in the output we get 23%
What is the way to solve it?
I guess that something is wrong with pctfmt format
proc format;
picture pctfmt low-high='000.00%';
run;
ods path work.templat(update) sashelp.tmplmst(read);
proc template;
edit Base.Freq.OneWayList;
edit Percent;
header="; Relative Frequency ;";
format=pctfmt.;
justify= on;
end;
edit CumPercent;
header = ";Cumulative;
Relative Frequency;";
format=pctfmt.;
justify= on;
end;
end;
run;
proc freq data=sashelp.cars;
tables Make / list;
run;
If it is helpful, SAS supports the PERCENTw.d format.
Try PERCENT8.2. If you have negative percentages, you can also use the PERCENTN8.2 format.
@Ronein wrote:
Hello
In following code i am trying to change format of one way proc freq.
For example :
For Make=Hummer frequency=1 and Relative Frequency should be 1/428=0.23%
But in the output we get 23%
What is the way to solve it?
I guess that something is wrong with pctfmt format
proc format; picture pctfmt low-high='000.00%'; run; ods path work.templat(update) sashelp.tmplmst(read); proc template; edit Base.Freq.OneWayList; edit Percent; header="; Relative Frequency ;"; format=pctfmt.; justify= on; end; edit CumPercent; header = ";Cumulative; Relative Frequency;"; format=pctfmt.; justify= on; end; end; run; proc freq data=sashelp.cars; tables Make / list; run;
Digit selectors in Picture formats don't always work the way you think they will until you have worked with them a lot.
Typically the formats suggest by @Rick_SAS are likely what you want.
I also think this is the format you may have intended to basically duplicate that 8.2 (or similar range) would be:
proc format library=work; picture pctfmt low-high='009.99%'; run;
The non-zero values in the string will force a character before the decimal, 0 if no actual value of 1 or greater in the data, and the non-zero after the decimal will always display 2 characters as appropriate (data will be truncated not rounded). Without any non-zero characters in the display string values that are less than 1 , such as your .23 don't really have a good alignment with the picture.
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.