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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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