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 ?
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.
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
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?
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.