BookmarkSubscribeRSS Feed
librasonali
Quartz | Level 8

Hi,

 

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 year_month ;
Run;

Gives me the frequencies like follows

202108 1.06E+08
202109 1.05E+08
202110 1.02E+08
202111 1.04E+08
202112 1.01E+08
202201 98690488
202202 81642710



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

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

Help appreciated! how can i use PROC Template.? not able to figure out syntax

3 REPLIES 3
FreelanceReinh
Jade | Level 19

Hi @librasonali,

 

I would write the PROC FREQ output to a dataset (OUT= option of the TABLES statement) and then use PROC PRINT or PROC REPORT to display the frequencies (and percentages if needed) in the desired format. Here's an example including the cumulative frequencies and percentages (via the OUTCUM option):

proc freq data=sashelp.heart;
tables smoking_status / out=want outcum missing;
run;

proc print data=want;
format count cum_freq comma12.
       percent cum_pct 6.2;
run;

(The FORMAT= option of the TABLES statement applies to crosstabulations.)

ballardw
Super User

In addition to @FreelanceReinh for variables that may have lots of values you might consider the NOPRINT option on the Proc Freq statement along with the OUT= to create a data set. No reason to create two output tables if not needed.

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1567 views
  • 1 like
  • 4 in conversation