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
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.
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.
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.
@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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.