BookmarkSubscribeRSS Feed
deleted_user
Not applicable
How do I write data to a semicolon sepr. file with no spaces before the semicolon?

the code (example)

data _null_
file "c:\temp\file.csv";
set sashelp.class;
put name';'sex ';'age;
run;

gives the result (please notice the spaces before the semicolon)

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


Should it alle be put in to a compressed string or what?
The case is complicated by the fact that char.vars should be in quotes in the output as in this example (but still with no spaces):

"Alfred" ;"M" ;14
"Alice" ;"F" ;13
"Barbara" ;"F" ;13
"Carol" ;"F" ;14
"Henry" ;"M" ;14
3 REPLIES 3
GertNissen
Barite | Level 11
Try
[pre]
data _null_;
set sashelp.class;
file "c:\temp\file.csv" dsd;
put name +(-1) ';' sex +(-1) ';' age;
run;
[/pre]
deleted_user
Not applicable
Thanks,

The lesson must be "RTFM" :-))
deleted_user
Not applicable
Geniz is right but not making full use of SAS. Try

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

SAS allows you to specify the delimitter to use with the DSD. Makes life very easy.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 955 views
  • 0 likes
  • 2 in conversation