BookmarkSubscribeRSS Feed
Sarojkumar
Calcite | Level 5
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.
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
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
Peter_C
Rhodochrosite | Level 12
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
deleted_user
Not applicable
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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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