DATA Step, Macro, Functions and more

Adding more decimals to the proc freq procedure

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Adding more decimals to the proc freq procedure

I want to add more decimal places to the percent column of the output created by proc freq in sas. I have a percent now of 87.76 but I would like this to 4 decimal places. The template for this is Base.Freq.OneWayFreqs. The code I am currently using is:

 

proc freq data=cat;

table food;

weight weight;

run;

 

 


Accepted Solutions
Solution
‎05-29-2017 07:35 PM
Contributor
Posts: 65

Re: Adding more decimals to the proc freq procedure

You can edit the template.  

 

* use ODS PATH statement so that you don't overwrite templates ;
* that shipped with SAS! ;

ODS PATH WORK.TEMPLAT(UPDATE) SASHELP.Tmplmst(READ);

proc template;
  edit Base.Freq.OneWayList;  
	edit Percent;
	  format=7.4 ;           
	end;
	edit CumPercent;
	  format=7.4 ;
	end;
  end;
run;

proc freq data=sashelp.class;
  tables height weight;
run;

* delete the edited template ;

proc template;
  delete Base.Freq.OneWayList;
run;

View solution in original post


All Replies
Super User
Posts: 3,105

Re: Adding more decimals to the proc freq procedure

One way to get what you want is to output a table in PROC FREQ and then use PROC PRINT as this example shows:

 

http://support.sas.com/documentation/cdl/en/procstat/68142/HTML/default/viewer.htm#procstat_freq_exa...

 

Solution
‎05-29-2017 07:35 PM
Contributor
Posts: 65

Re: Adding more decimals to the proc freq procedure

You can edit the template.  

 

* use ODS PATH statement so that you don't overwrite templates ;
* that shipped with SAS! ;

ODS PATH WORK.TEMPLAT(UPDATE) SASHELP.Tmplmst(READ);

proc template;
  edit Base.Freq.OneWayList;  
	edit Percent;
	  format=7.4 ;           
	end;
	edit CumPercent;
	  format=7.4 ;
	end;
  end;
run;

proc freq data=sashelp.class;
  tables height weight;
run;

* delete the edited template ;

proc template;
  delete Base.Freq.OneWayList;
run;
☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 209 views
  • 2 likes
  • 3 in conversation