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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.