Programming the statistical procedures from SAS

How come the percent format isn't working for proc means?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 88
Accepted Solution

How come the percent format isn't working for proc means?

I'm trying to format the mean as a percentage. this is the code I used:

proc means data=omrswork;
where count_carf1 >0 and count_carf2=0 and count_carf3=0 and count_carf4=0 and dc_fiscal_year=2 and dc_fiscal_year^=99 and percent_nscx^=.;
var percent_nscx;
format dc_fiscal_year fiscalyear. percent_nscx percent8.2 site site.;
run; 

How come the percent.8.2 format isn't working for the actual mean that is calculated?

 

When I run the proc means, the mean is still in decimal form.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Accepted Solutions
Solution
‎08-31-2016 01:23 PM
Super User
Posts: 5,255

Re: How come the percent format isn't working for proc means?

Christina,

 

This is a topic that has tripped up many people.  Here is the combination of factors at work:

 

  • The format is being applied to the variable PERCENT_NSCX.
  • PROC MEANS doesn't print PERCENT_NSCX.

Since PROC MEANS is calculating statistics, and printing the statistics (not the original variable), the format is ignored.

 

Theoretically, you could ask PROC MEANS to create an output data set.  Then print the output data set while adding a FORMAT statement.

View solution in original post


All Replies
Solution
‎08-31-2016 01:23 PM
Super User
Posts: 5,255

Re: How come the percent format isn't working for proc means?

Christina,

 

This is a topic that has tripped up many people.  Here is the combination of factors at work:

 

  • The format is being applied to the variable PERCENT_NSCX.
  • PROC MEANS doesn't print PERCENT_NSCX.

Since PROC MEANS is calculating statistics, and printing the statistics (not the original variable), the format is ignored.

 

Theoretically, you could ask PROC MEANS to create an output data set.  Then print the output data set while adding a FORMAT statement.

Frequent Contributor
Posts: 88

Re: How come the percent format isn't working for proc means?

Thanks Astounding! this is helpul to knowSmiley Happy

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 277 views
  • 2 likes
  • 2 in conversation