SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Formating number 0.000 with SAS

Reply
New Contributor
Posts: 4

Formating number 0.000 with SAS

Good afternoon,

i`m currently producing a csv txt file with around 500.000 lines using SAS on mainframe (zos).

It has around 40 columns and its majority are numeric.

At certain point of my program i use the following to format the numbers :

      FORMAT field1 field2 field3 field4 field5 field6  8.4;

My goal is to reduce the file output report size and since a lot of data is 0.0000 i thought i could replace this by 0 only.

This would save 5 characters and certainly would save some space.

Any ideia on how could i do this ?

Super User
Posts: 3,101

Re: Formating number 0.000 with SAS

The BEST format could do what you want. Try BEST8. - this will ensure 0 just shows as 0 and decimals like 12.34 will show as 12.34.

Trusted Advisor
Posts: 1,128

Re: Formating number 0.000 with SAS

I believe picture format will work, please replace 8.4 with picture the below picture format

proc format fmtlib;

picture pct 0='9'

      0<-high='09.9999';

   run;

data have;

input x;

cards;

0

8.99

8.12

8.3

;

data want;

set have;

format x pct.;

run;

Thanks,

Jag

Thanks,
Jag
Respected Advisor
Posts: 3,777

Re: Formating number 0.000 with SAS

Back in the day we used implied decimal in-formatting.  How much space would getting rid of ALL the decimal points save?

How much more space would you save if you got rid of the field delimiters?

Super User
Super User
Posts: 6,497

Re: Formating number 0.000 with SAS

I assume you wanted to apply the format to limit the display of non-significant precision in the numbers.  You would probably have the best results by rounding the values to 4 decimal places and then letting SAS format the values using BEST format.

data _null_;

   set mydata ;

   array f field1-field8 ;

   do over f; f=round(f,0.0001); end;

   file 'myfile.csv' dsd ;

   format field1-field8 ;

   put (_all_) (Smiley Happy ;

run;

Ask a Question
Discussion stats
  • 4 replies
  • 400 views
  • 0 likes
  • 5 in conversation