BookmarkSubscribeRSS Feed
renjithr
Quartz | Level 8

Hi All,

 

I am creating a .csv file in mainframe using SAS and email the file as an attachment. When I open the file the numeric data, for example, customer id 1234567898 is converted into 123E.11 something like that.

 

Could you please let me know how I can retain the format of the numeric variable in .CSV file( I know when I open the .csv file in Excel this weird conversion happens). 

 

Please help.

 

Thanks

3 REPLIES 3
ballardw
Super User

Don't open in Excel, or make the columns wider the appearnce should change.. CSV does not have any format information in the file, it is only text.

Reeza
Super User
Open the CSV in a text editor (Notepad/Wordpad) and verify the data. Excel is most likely making the conversion automatically. Very nice of it. Usually making the cell bigger will change the format to a number. You can also, try to make it a character variable and make sure you export it as a quoted variable and then Excel MAY read it properly. Not always...
renjithr
Quartz | Level 8

Hi All,

 

Thanks for the reponse.

 

Here is how I finally achieved retining the format of numeric variable in .CSV file.

 

data _null_;

 file filout;

 if _n_=1 then do;

  put @1 '="'

         @2 'Num variable'

         @10 '"';

end;

put @2 num_var;

run;

The above trick works!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 4944 views
  • 0 likes
  • 3 in conversation