BookmarkSubscribeRSS Feed
onurhok
Calcite | Level 5

Hi all,

 

I am exporting a SAS dataset as CSV file with the following code: 

 

proc export data=data_new
outfile= path
dbms=csv
replace;
delimiter=';';
run;

 

The numbers in thousands in SAS data looks like: 25678.54678

However in csv file, it looks like: 2.567.854.678. So basically, in csv, the number is regarded as without decimals.

 

How can I fixed this issue?

 

6 REPLIES 6
andreas_lds
Jade | Level 19

Does not happen:

data narf;
   set sashelp.class;

   Weight = Weight * 12345.67;
run;

proc export data=narf dbms=dlm outfile="export_sep_test.csv" replace;
   delimiter=';';
run;

export_sep_test.png

So please, run proc contents on the dataset and post the result.

Kurt_Bremser
Super User

You may have an issue with formatting, because this works:

data data_new;
number = 25678.54678;
run;

filename out temp;

proc export data=data_new
outfile=out
dbms=csv
replace;
delimiter=';';
run;

data _null_;
infile out;
input;
put _infile_;
run;

Log excerpt:

 110        data _null_;
 111        infile out;
 112        input;
 113        put _infile_;
 114        run;
 
 NOTE: The infile OUT is:
       Dateiname=/saswork/SAS_work95BE0000BA3C_odaws01-euw1.oda.sas.com/#LN00119,
       Besitzername=kurt.bremser,Gruppenname=oda,
       Zugriffsberechtigung=-rw-r--r--,
       Zuletzt geändert=12. April 2022 15.24 Uhr,
       Dateigröße (Byte)=19
 
 number
 25678.54678

The number is written to the file as intended.

Please run a PROC CONTENTS of your dataset data_new and post the output line for the variable that does not come out right.

 

How did you inspect your csv file?

onurhok
Calcite | Level 5

this is how the column looks like in SAS:

onurhok_0-1649770413132.png

 

When I open csv file, I see this: 

onurhok_1-1649770476279.png

 

Num820.5
Kurt_Bremser
Super User

This is not what the file looks like. This looks rather like an Excel screenshot.

As I already said, do NOT (as in NOT) inspect the file with Excel. Open it with a text editor.

andreas_lds
Jade | Level 19

Please open the csv-file with a text editor, like notepad++. If excel shows formatting not meeting your expectations, than most likely excel applied one of its fantastic optimizations.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 5902 views
  • 0 likes
  • 3 in conversation