Help using Base SAS procedures

How to convert the format of the numbers in SAS results

Accepted Solution Solved
Reply
Regular Contributor
Posts: 173
Accepted Solution

How to convert the format of the numbers in SAS results

HI ,

I am working with a dataset with roughly 87 million cases (87,195,470 to be exact).

And the SAS output that is generated is showing some of the numbers in a different format.

For instance; as below;

Any suggestions how I can get SAS to show we whole numbers or how to manually convert these results to get a correct whole number?Any help would be greatly appreciated.

Best,

Ashwini

1
2.155E8
50.52
97.67
51.59
5142105
1.21
2.33
58.34
2.206E8
51.72
2
4.566E7
10.71
98.07
10.93
899689
0.21
1.93
10.21
4.656E7
10.92
3
4.192E7
9.83
98.71
10.04
545909
0.13
1.29
6.19
4.247E7
9.96
4
8327958
1.95
97.97
1.99
172916
0.04
2.03
1.96
8500874
1.99
5
1.277E7
2.99
98.33
3.06
217178
0.05
1.67
2.46
1.299E7
3.05
6
9.354E7
21.93
98.07
22.39
1836836
0.43
1.93
20.84
9.537E7
22.36
Total
4.177E8
97.93
8814633
2.07
4.265E8
100.00
Frequency Missing = 451436.57331

Accepted Solutions
Solution
‎01-20-2015 02:20 PM
SAS Super FREQ
Posts: 8,743

Re: How to convert the format of the numbers in SAS results

Hi:

  PROC FREQ directly supports the FORMAT= option in the TABLE statement, too: So a Table Template might not be needed.

Base SAS(R) 9.4 Procedures Guide: Statistical Procedures, Second Edition

cynthia

View solution in original post


All Replies
Super User
Posts: 10,538

Re: How to convert the format of the numbers in SAS results

What procedure is generating the output? A specific example of the code used or generated would be helpful.

One approach would be to use a modified table template with a different default format.

Another would be to direct the output to a dataset and use proc print or another display procedure and assign a different format to allow for large values using a best16. format perhaps.

Regular Contributor
Posts: 173

Re: How to convert the format of the numbers in SAS results

Below is the code and all numbers inthe output should be weighted numbers..

proc freq data= library.nis0111ARFall;

tables amonth season female racecat income hosp_region hosp_location hosp_teach year died)/ missing;

weight discwt;

run;

Super User
Posts: 10,538

Re: How to convert the format of the numbers in SAS results

The below code temporarily modifies the basic format of the frequency column used in proc freq with a small example date set.

ods path sasuser.templat(update) sashelp.tmplmst(read);

proc template;                                                               
   define column Base.Freq.Frequency;                                        
      notes "Parent for FREQ Frequency columns";                             
      header = "Frequency";                                                  
      format = BEST16.;                                                       
      just = c;                                                              
   end;                                                                      
run; 

data junk;
input var wt;
datalines;
1 123456789
2 3453453453
;
run;

proc freq data=junk;
table var;
weight wt;
run;

/* This resets back to default*/

proc template;
delete Base.Freq.Frequency;
end;

Solution
‎01-20-2015 02:20 PM
SAS Super FREQ
Posts: 8,743

Re: How to convert the format of the numbers in SAS results

Hi:

  PROC FREQ directly supports the FORMAT= option in the TABLE statement, too: So a Table Template might not be needed.

Base SAS(R) 9.4 Procedures Guide: Statistical Procedures, Second Edition

cynthia

Super User
Posts: 10,538

Re: How to convert the format of the numbers in SAS results

I haven't access to 9.4 yet so that's my quickest solution for a specific issue. Something else to look forward too when I can get our support staff to get us up to speed.

Regular Contributor
Posts: 173

Re: How to convert the format of the numbers in SAS results

Thanks very much Cynthia for your timely response! It was helpful and it worked!

It worked for the cross tables using Proc freq. However it didn't work for the proc freq for plain frequncies. Any idea what the reason may be? Is there any way I can get the whole numbers in the plain frequencies (no cross tables). Thanks again!

Here are my codes:

proc freq data= library.nis0111ARFall; Didn't work for this.

tables amonth season female racecat income hosp_region hosp_location hosp_teach year died/ missing format= BEST16.;

weight discwt;

run;

*Bivariate*/;

proc freq data= library.nis0111ARFall; Worked for this one

tables female*died hosp_region*died  hosp_location*died hosp_teach*died  racecat*died  racenew*died income*died

hosp_region * year/ chisq format=BEST16.;

weight discwt;

run;

Regular Contributor
Posts: 173

Re: How to convert the format of the numbers in SAS results

@ Ballardw: thanks for your elaborate response! Appreciate it! But me being just a intermidiate level programmer, it was difficult for me to follow this. Smiley Happy

I use SAS mostly to do stats so not much aware of most formatting/programming aspects of SAS procs.

Super User
Posts: 10,538

Re: How to convert the format of the numbers in SAS results

Basically, run the proc template define code provided.

After you're done run the proc template delete, unless you want that behavior to be the new default for all proc freq output.

☑ This topic is solved.

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

Discussion stats
  • 8 replies
  • 581 views
  • 4 likes
  • 3 in conversation