DATA Step, Macro, Functions and more

Formatting Scientific Notation in PROC FREQ

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

Formatting Scientific Notation in PROC FREQ

I see that when I apply proc freq on a variable in a large dataset, the result gets truncated to scientific notation. Eg. for the below on a dataset of 35 Million records

Proc freq data=sales;
Tables region;
Run;

Gives me the frequencies like follows

US 2.15E8
UK. 1.59E7
EMEA 100000

I want the numbers to appear completely with a comma separator.

I tried using formats (best12. and comma12.) in the tables statment but to no avail.

Help appreciated!
Sasmaverick

Accepted Solutions
Solution
‎12-26-2016 04:04 AM
Super User
Posts: 17,818

Re: Formatting Scientific Notation in PROC FREQ

Switch to proc tabulate and you can format the numbers easily. Otherwise google 'PROC FREQ TEMPLATE' for examples on how to modify the template for PROC FREQ to have it show the values as you want. 

View solution in original post


All Replies
Solution
‎12-26-2016 04:04 AM
Super User
Posts: 17,818

Re: Formatting Scientific Notation in PROC FREQ

Switch to proc tabulate and you can format the numbers easily. Otherwise google 'PROC FREQ TEMPLATE' for examples on how to modify the template for PROC FREQ to have it show the values as you want. 

Super User
Posts: 9,676

Re: Formatting Scientific Notation in PROC FREQ

An alternative way is using SQL.

proc sql;
create table want as
 select region,count(*) as count format=f12.
  from sales
   group by region;
quit;

Contributor
Posts: 64

Re: Formatting Scientific Notation in PROC FREQ

Thank you, I was able to do it by setting default formats for frequencies by using PROC Template.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 503 views
  • 0 likes
  • 3 in conversation