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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1600 views
  • 0 likes
  • 2 in conversation