BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
anjankumar08
Calcite | Level 5

Hi guys,

 

I'm facing issue while converting SAS dataset to CSV. Character variable is converting to numeric in CSV file and missing trailing zeros. Below is the example.

 

SAS Dataset: 

employy
1004.13100
1004.13140
1003.45620

 

after converting to CSV it is showing in numeric and missing trailing zeros

employy
1004.131
1004.1314
1003.4562

 

Need help. Appreciated 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Because Excel is interpreting the data when it reads it in. It shouldn't but it does. To avoid this open Excel, Data Tab>Import CSV/Text.
Set Data Detection to Do Not Detect Types.

View solution in original post

9 REPLIES 9
anjankumar08
Calcite | Level 5

Here is the code

 


PROC EXPORT DATA= XXX
OUTFILE= "C:\temp\test.csv"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;

Reeza
Super User

How did you 'check' your file? If you opened it in Excel, Excel does it's own interpretation of the CSV. Make sure to check the output using a text editor such as Notepad++.

 


@anjankumar08 wrote:

Here is the code

 


PROC EXPORT DATA= XXX
OUTFILE= "C:\temp\test.csv"
DBMS=CSV REPLACE;
PUTNAMES=YES;
RUN;


 

anjankumar08
Calcite | Level 5

Hi,

 

It's showing correct in Notepad++ 

 

Thank you

anjankumar08
Calcite | Level 5
Why it is like this? Why it is not showing correct in CSV?
ballardw
Super User

@anjankumar08 wrote:
Why it is like this? Why it is not showing correct in CSV?

What application are you using to look at the CSV file?

 

If you opened the file with Excel, and possibly other spreadsheets, and then SAVED the file when closing then you may very well have permanently altered the contents. As @Reeza said.

 

Reeza
Super User
Because Excel is interpreting the data when it reads it in. It shouldn't but it does. To avoid this open Excel, Data Tab>Import CSV/Text.
Set Data Detection to Do Not Detect Types.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 9 replies
  • 2263 views
  • 0 likes
  • 4 in conversation