BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bayzid
Obsidian | Level 7

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?

Capture.PNG

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MayurJadhav
Quartz | Level 8

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:

MayurJadhav_1-1683669241494.png

 

 

PROC FREQ with FORMAT

proc freq data=OneBillionRows;
   tables Rank*Rank / list all  format=comma14. ; 
run;

Output:

MayurJadhav_0-1683669180388.png

 

Mayur Jadhav
BI Developer. Writer. Creative Educator.

SAS Blog → https://learnsascode.com
YouTube Channel: → https://www.youtube.com/@imayurj

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
MayurJadhav
Quartz | Level 8

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:

MayurJadhav_1-1683669241494.png

 

 

PROC FREQ with FORMAT

proc freq data=OneBillionRows;
   tables Rank*Rank / list all  format=comma14. ; 
run;

Output:

MayurJadhav_0-1683669180388.png

 

Mayur Jadhav
BI Developer. Writer. Creative Educator.

SAS Blog → https://learnsascode.com
YouTube Channel: → https://www.youtube.com/@imayurj
BayzidurRahman
Obsidian | Level 7

Thanks very much.

bayzid
Obsidian | Level 7

I am using the following code but still the same result.
proc freq data=sas.dosemed_all; tables ScheduleType/list all format=comma14.; run;

Watts
SAS Employee

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;
BayzidurRahman
Obsidian | Level 7
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
Watts
SAS Employee

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

MayurJadhav
Quartz | Level 8

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;

MayurJadhav_0-1683728809847.png

 

Mayur Jadhav
BI Developer. Writer. Creative Educator.

SAS Blog → https://learnsascode.com
YouTube Channel: → https://www.youtube.com/@imayurj

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1056 views
  • 6 likes
  • 6 in conversation