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

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SuzanneDorinski
Lapis Lazuli | Level 10

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

2 REPLIES 2
SASKiwi
PROC Star

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...

 

SuzanneDorinski
Lapis Lazuli | Level 10

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 9438 views
  • 2 likes
  • 3 in conversation