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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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