BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ypss
Calcite | Level 5

Hello

I have a problem - when I try to export a dataset to delimited txt file using data step export, I experience a small but annoying issue that is probably limited to this way of exporting a file because proc export does the job just fine.  Unfortunately I need to provide changes to this txt file that proc export can't do so using it is not the solution. So... the thing is - I have in my dataset columns that are always filled with some data and some that are not and in the txt file these empty cells look like this:

, ,

What I want is ,,.  How can I remove this blank space betweem delimiter?

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

I believe you're looking for "DSD".

ods _all_ close;

ods listing;

options missing='';

data _null_;

  set sashelp.class;

  file print delimiter=',' DSD;

  if _n_=2 then call missing(Sex,Age,Name);

  put Height Sex Age Name Weight;

run;

View solution in original post

4 REPLIES 4
Patrick
Opal | Level 21

It would really help if you would post your code - especially the bit where you're actually writing to the text file.

So just purely guessing here:

You might be looking for something like PUT VAR1 +(-1) ',' VAR2 .....;

Ypss
Calcite | Level 5

My code:

data _null_ ;         

    set WORK.Files;

    file  outfile delimiter=','; 

if _n_ = 1 then do;

PUT 'A,B,C,D';

end;

PUT A B C D;

run ;

The output is:

A~B~C~D

F1,235, ,

What I want is:

A~B~C~D

F1,235,,,

Patrick
Opal | Level 21

I believe you're looking for "DSD".

ods _all_ close;

ods listing;

options missing='';

data _null_;

  set sashelp.class;

  file print delimiter=',' DSD;

  if _n_=2 then call missing(Sex,Age,Name);

  put Height Sex Age Name Weight;

run;

Ypss
Calcite | Level 5

That's it! Thank you!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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