DATA Step, Macro, Functions and more

Want to creat a .csv file with ; as separator

Reply
Occasional Contributor
Posts: 14

Want to creat a .csv file with ; as separator

I want to create a .CSV file from SAS dataset with ';' as the separator. I tried both the folloiwng options with all the delimiters, it works fine for all other delimiters except ";"

data _null_;
set sashelp.class;
file "C:\temp\test1.csv" dsd dlm="," ;
put name sex age;
run;

and

PROC EXPORT DATA= work.saroj
OUTFILE= "C:\temp\test1.csv"
DBMS=CSV REPLACE;
delimeter = '|';
RUN;


My output should be the following with ; as the separator.

Alfred;M;14
Alice;F;13
Barbara;F;13
Carol;F;14
Henry;M;14

But the above values are displayed in separate columns as

Alfred M 14
Alice F 13
Barbara F 13
Carol F 14
Henry M 14
James M 12
Jane F 12
Janet F 15

Any help on this.
SAS Super FREQ
Posts: 8,864

Re: Want to creat a .csv file with ; as separator

Posted in reply to Sarojkumar
Hi:
Using ODS CSV and PROC PRINT, you can get the ';' as a delimiter. There have been previous forum postings on this topic:
http://support.sas.com/forums/thread.jspa?messageID=29025煡
http://support.sas.com/forums/thread.jspa?threadID=5414
http://support.sas.com/forums/thread.jspa?messageID=19459䰃


cynthia
Valued Guide
Posts: 2,177

Re: Want to creat a .csv file with ; as separator

Posted in reply to Sarojkumar
Sarojkumar

Which release of SAS are you using?
In the data step, why not set dlm= ";" ?
It works for me!

In the proc export code, why use '|' when you want ';' ?

If it's not working, show us your log!

hth
peterC
N/A
Posts: 0

Re: Want to creat a .csv file with ; as separator

Posted in reply to Sarojkumar
i agree with peterc.

here is the code: (there was syntax error with proc export)

data _null_;
set sashelp.class;
file "C:\temp\test1.csv" dsd dlm=";" ;
put name sex age;
run;

PROC EXPORT DATA= sashelp.class
OUTFILE= "C:\temp\test1.csv"
DBMS=CSV REPLACE ;
delimiter = ';';
RUN;
Ask a Question
Discussion stats
  • 3 replies
  • 165 views
  • 0 likes
  • 4 in conversation