I have a very large number in a frequency table which SAS is abbreviating in the output as below. How can i get SAS to report all the digits?
Hi @bayzid , You need to mention format after forward "table vars / "
format=comma14.
Refer this simple example where I've created 1B rows with same value (A++). It means when I run proc freq without any format, I'll also get the same value in hexadecimal format.
/* create a new dataset with 1B rows*/
data OneBillionRows (keep=rank);
do i=1 to 1000000000;
rank='A++';
output;
end;
run;
PROC FREQ without Format:
proc freq data=OneBillionRows;
tables Rank*Rank / list all ;
run;
Output:
PROC FREQ with FORMAT
proc freq data=OneBillionRows;
tables Rank*Rank / list all format=comma14. ;
run;
Output:
see https://support.sas.com/resources/papers/proceedings17/SAS0404-2017.pdf
And hint hint hint for next time, I think you will get faster answers if you do a simple search first. I found that via a simple internet search for:
How to change formats in PROC FREQ
which took me less time than it takes to write a post here.
Hi @bayzid , You need to mention format after forward "table vars / "
format=comma14.
Refer this simple example where I've created 1B rows with same value (A++). It means when I run proc freq without any format, I'll also get the same value in hexadecimal format.
/* create a new dataset with 1B rows*/
data OneBillionRows (keep=rank);
do i=1 to 1000000000;
rank='A++';
output;
end;
run;
PROC FREQ without Format:
proc freq data=OneBillionRows;
tables Rank*Rank / list all ;
run;
Output:
PROC FREQ with FORMAT
proc freq data=OneBillionRows;
tables Rank*Rank / list all format=comma14. ;
run;
Output:
Thanks very much.
I am using the following code but still the same result.
proc freq data=sas.dosemed_all; tables ScheduleType/list all format=comma14.; run;
To format frequencies in a one-way frequency table, you can use the ONEWAY(FORMAT=) option in the TABLES statement.
proc freq data=sas.dosemed_all; tables ScheduleType / oneway(format=comma14.); run;
14799 proc freq data=sas.dosemed_all;
14800 tables ScheduleType / oneway(format=comma14.);
------ -
22 22
202 200
ERROR 22-322: Syntax error, expecting one of the following: ;, AGREE, ALL, ALPHA, BDT, BIN,
BINOMIAL, CELLCHI2, CHISQ, CL, CMH, CMH1, CMH2, COMMONRISKDIFF, COMONMRDIFF,
CONTENTS, CONVERGE, CROSSLIST, CUMCOL, DEVIATION, EXACT, EXPECTED, FISHER,
FORMAT, GAILSIMON, GS, JT, KAPPA, LINE, LIST, MAXITER, MAXLEVELS, MEASURES,
MISSING, MISSPRINT, NOCOL, NOCUM, NOFREQ, NOPERCENT, NOPRINT, NOROW, NOSPARSE,
NOWARN, ODDSRATIO, OR, OUT, OUTCUM, OUTEXPECT, OUTPCT, PEARSONRES, PEARSONRESID,
PLCORR, PLOTS, PRINTKWTS, PRINTWTS, RELRISK, RISKDIFF, SCORE, SCORES, SCOROUT,
SENSPEC, SPARSE, STDRES, STDRESID, TABLE, TESTF, TESTP, TOTPCT, TREND, WARN.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
ERROR 200-322: The symbol is not recognized and will be ignored.
14801 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
The ONEWAY(FORMAT=) option is available in PROC FREQ beginning in release 2020.1 (Viya 4).
Alternatively, you can change the format of frequencies in one-way tables by modifying the template. There's an example in Usage Note 37442: Modifying the OneWayFreqs template.
As explained by @Watts, Base.Freq.OneWayFreqs can solve this formatting problem.
Here is the same example adjusted according to what you're looking for! @bayzid
ods path reset;
ods path (prepend) work.templat(update);
ods path show;
proc template;
edit Base.Freq.OneWayFreqs; column Line FVariable FListVariable Variable Frequency
TestFrequency Percent TestPercent CumFrequency CumPercent;
edit frequency;
format=comma14.;
end;
edit percent;
format=8.3;
end;
end;
run;
proc freq data=OneBillionRows;
tables Rank / list all nocum ;
run;
proc template;
delete Base.Freq.OneWayFreqs;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.