Hi,
I need to export dataframes calculated in SAS to csv with 16 decimal places. How do this ? is there an option in proc export ?
proc export data=sas-dataset-name outfile='/path/to/output/filename.csv' dbms=csv replace; run;
If you got your dataframe result to a SAS dataset, you can formats to the columns you need to have a specified numger of decimals:
proc datasets lib=library-name;
modify sas-dataset-name;
format variable-name 22.16;
run;
quit;
How critical are the 15th and 16th decimal places? If very critical then a basic SAS data set may not be where this belongs due to precision of storage.
Note that the 16th digit will not be reliable stored in SAS numbers. See Numerical Precision discussion in the documentation:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p0dv87zb3bnse6n1mqo360be70qr.htm
To control how values are PRINTED in SAS you can attach a FORMAT to the variable. The EXPORT produces just uses a normal data step with PUT statement to write the CSV file. So whatever format was attached to the variable will be used.
16 digits total? You might try using BEST17. (leaving one space for the decimal point). Or perhaps BEST18. if you have any negative values.
16 to the right of the decimal point? How many to the left of the decimal point? Use 18.16 to write 16 to the right of the decimal point, a decimal point, and one digit to the left.
Or something else?
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.