BookmarkSubscribeRSS Feed
MainframeSAS
Calcite | Level 5

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 ?

4 REPLIES 4
SASKiwi
PROC Star

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.

Jagadishkatam
Amethyst | Level 16

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
data_null__
Jade | Level 19

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?

Tom
Super User Tom
Super User

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_) (:) ;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1625 views
  • 0 likes
  • 5 in conversation