BookmarkSubscribeRSS Feed
baskisb
Calcite | Level 5

Hi , 

 

Im using proc export with DBMS = csv and replace option and the email getting generated to outbound location.

 

But what i observed the the columns which has character values in SAS dataset ( for example : Classfication : 1,2,3 ( in char)  ; Flag = 4,7,1 ( in char) ) those are changing as numeric when i open csv file on email.its automatically changing char to numeric as right alignment .

 

Could you please help in proc export how do we fix this , kindly help on this case.

 

Thanks

Venkat

4 REPLIES 4
s_lassen
Meteorite | Level 14

I think the problem is with whatever application you use to read the .csv-file. PROC EXPORT very nicely puts quotes around values like that, so it should be read as a single character value. 

 

One workaround may be to change the delimiter to ';', if your application can understand that as a delimiter. Otherwise, use some other application to view the file.

andreas_lds
Jade | Level 19

Let me guess: you are using Excel to display the csv-file, right? Try using a text-editor, that has not the fancy habits Excel has.

Kurt_Bremser
Super User

I ran this code

data have;
input var1 $ var2 $ var3;
datalines;
A 1,2,3 5
;

proc export
  data=have
  file="/folders/myfolders/have.csv"
  dbms=csv
  replace
;
run;

and got this in the file:

var1,var2,var3
A,"1,2,3",5

which is as it should be.

Opening the file with LibreOffice also resulted in a left-aligned string.

Tom
Super User Tom
Super User

@baskisb wrote:

Hi , 

 

Im using proc export with DBMS = csv and replace option and the email getting generated to outbound location.

 

But what i observed the the columns which has character values in SAS dataset ( for example : Classfication : 1,2,3 ( in char)  ; Flag = 4,7,1 ( in char) ) those are changing as numeric when i open csv file on email.its automatically changing char to numeric as right alignment .

 

Could you please help in proc export how do we fix this , kindly help on this case.

 

Thanks

Venkat


A CSV file is jut plain text. It has no metadata about the type of data in contains (other than the optional header row).  

What program are you using to view the CSV file?  If it is Excel you need to do a little work to tell it what data type to use for each column.

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
  • 4 replies
  • 1363 views
  • 1 like
  • 5 in conversation