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

I am using SAS EG 7.1. The variables that I tabulating have a lot of zeros after the decimal point and I would like to see all decimal points until the first non-zero digit. So I use the format option. The format works fine in the results window. However the output file still shows the scientific notation (e.g. 1.6E-07). How can I make sure the the results and output file have the same format?  

 

proc tabulate data=example out=out_example (drop=_:) format=20.15;
class year;
var          var1 var2 var3;
table year, (var1 var2 var3)*(mean) (N);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

If the goal is to make a dataset why use PROC TABULATE?

Use PROC SUMMARY and the formats attached to the variables are carried onto the statistics.  You can even attach formats to the output statistics, but you could get a warning.

 

Try:

proc tabulate data=sashelp.class out=out_example (drop=_:) ;
  class sex;
  var age height weight ;
  table sex, (age height weight)*(mean*F=7.3) (N*F=7.);
run;

proc contents data=out_example;
run;

proc summary data=sashelp.class nway ;
  class sex;
  var age height weight ;
  output out=out_example2(drop=_type_ rename=(_freq_=N)) mean= / autoname;
  format age 7.3 ;
  format N 7.;
run;

proc contents data=out_example2;
run;

proc compare data=out_example compare=out_example2;
run;

 

View solution in original post

3 REPLIES 3
ballardw
Super User

The Format= option on the Proc statement is not applied to variables in the resulting data set as you have found out. The output data set created variables are assigned BEST12 formats.

 

You could either a assign a desired format when using the variables in any other procedure or use Proc Datasets to change the default. Something like:

Proc datasets library=work;
   modify out_example ;
      format  var1_mean var2_mean var3_mean 20.15;
   run;
quit;

 

 

Tom
Super User Tom
Super User

If the goal is to make a dataset why use PROC TABULATE?

Use PROC SUMMARY and the formats attached to the variables are carried onto the statistics.  You can even attach formats to the output statistics, but you could get a warning.

 

Try:

proc tabulate data=sashelp.class out=out_example (drop=_:) ;
  class sex;
  var age height weight ;
  table sex, (age height weight)*(mean*F=7.3) (N*F=7.);
run;

proc contents data=out_example;
run;

proc summary data=sashelp.class nway ;
  class sex;
  var age height weight ;
  output out=out_example2(drop=_type_ rename=(_freq_=N)) mean= / autoname;
  format age 7.3 ;
  format N 7.;
run;

proc contents data=out_example2;
run;

proc compare data=out_example compare=out_example2;
run;

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 657 views
  • 2 likes
  • 4 in conversation