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
Use the FORMAT option in the TABLES statement:
proc freq data=sales;
tables year_month / format=20.;
run;
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.)
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.
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.