BookmarkSubscribeRSS Feed
_Manhattan
Quartz | Level 8
data your_data;
numeric_value = -1.825189E15;
run;

ods excel file="path/to/output.xlsx" ; proc report data=mydata ; columns _ALL_ ; run ; ods excel close ;

 You could try ods excel in combination with e. g. proc report instead of proc export, but I am not sure if that will produce your desired result. Could you provide some example code and data?

JosvanderVelden
SAS Super FREQ

Just run the code below and analize the csv file. You may need to change the filename statement.

filename csvfile '~/csvfile.csv' encoding=utf8;

data _null_;
   file csvfile;
   largenumber = -1825189000000000;
   largenumber_fmt = largenumber;
   format largenumber_fmt comma32.;
   put "not formatted " largenumber=;
   put "format comma32. " largenumber_fmt=;
   largenumber + -9999999999999999;
   largenumber_fmt = largenumber;
   put "What if largenumber = largenumber + -9999999999999999?";
   put "not formatted " largenumber=;
   put "format comma32. " largenumber_fmt=;   
   positivelargenumber = 9007199254740992;
   positivelargenumber_fmt = positivelargenumber;
   format positivelargenumber_fmt comma32.;   
   put "not formatted " positivelargenumber=;
   put "format comma32. " positivelargenumber_fmt=;   
   positivelargenumber + 1;
   positivelargenumber_fmt = positivelargenumber;
   put "What if positivelargenumber + 1?";
   put "not formatted " positivelargenumber=;
   put "format comma32. " positivelargenumber_fmt=;   
run;

 

Tom
Super User Tom
Super User

What FORMAT did you attach to the variable?

If you do not attach any format then SAS will use BEST12.  Which is what it looks like was used.

 

To have it print all of those digits you will need to use the normal numeric format with a width of at least 17.

 

If you want it to print like the example in your question then you would need to attach the COMMA format.  With a width of at least 22. 

 

Note that if you do use the COMMA format then the CSV file will add quotes around the value to protect the embedded delimiters.

 

data have;
  id +1 ;
  input number ;
cards;
-1825189000000000
;
697  data _null_;
698    set have;
699    file log dsd ;
700    put id number;
701    put id number :17. ;
702    put id number :comma22. ;
703  run;

1,-1.825189E15
1,-1825189000000000
1,"-1,825,189,000,000,000"
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
Reeza
Super User

Use formats

 

Reeza_0-1689956441299.png

 

Quentin
Super User

There are lots of ways to export a dataset to CSV.  Which are you using?  Can you post a full, reproducible example?  Something like:

 

data have ;
  x=  -1825189000000000 ;
run ;

*your code to export to CSV here ;
BASUG is hosting free webinars ! Check out recordings of our past webinars: https://www.basug.org/videos. Save the date for our in person SAS Blowout on Oct 18 in Cambridge, MA. Registration opens in September.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 19 replies
  • 1895 views
  • 2 likes
  • 9 in conversation