Removing Blanks

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Removing Blanks

Hello,

 

I am doing a SAS export into CSV using delimiters. How do I remove the space between the pipes for numeric variables only? The code is already set up to have blank character variables in quotes. I tried using DSD and this resolved the problem with numeric variables but created extra quotes within the character variables.

 

data _null_;
set TOTAL.FINAL_FOR_OUTPUT_&Output_Date.;
file ".csv" dlm='|' ls = 5000;
if _n_ eq 1 then link names;
put (_all_)(Smiley Happy;
format _character_ $quote128.;
return;
names:
length _name_ $32;
do while(1);
call vnext(_name_);
if upcase(_name_) eq '_NAME_' then leave;
put _name_ @;
end;
put;
run;


Accepted Solutions
Solution
‎05-11-2016 08:53 AM
Trusted Advisor
Posts: 1,117

Re: Removing Blanks

Hello @mk131190,

 

Please replace 

 

put (_all_)(:);

by the following three lines of code:

 

put (_all_)(:) @;
_file_=tranwrd(_file_,'|.','|');
put;

The above suggestion assumes the default setting for system option MISSING:

options missing='.';

However, you could use other settings of this option as well. Just adapt the second argument of the TRANWRD function correspondingly.

View solution in original post


All Replies
Super Contributor
Posts: 308

Re: Removing Blanks

Occasional Contributor
Posts: 19

Re: Removing Blanks

I thought this was only possible for character variables?

Solution
‎05-11-2016 08:53 AM
Trusted Advisor
Posts: 1,117

Re: Removing Blanks

Hello @mk131190,

 

Please replace 

 

put (_all_)(:);

by the following three lines of code:

 

put (_all_)(:) @;
_file_=tranwrd(_file_,'|.','|');
put;

The above suggestion assumes the default setting for system option MISSING:

options missing='.';

However, you could use other settings of this option as well. Just adapt the second argument of the TRANWRD function correspondingly.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 359 views
  • 1 like
  • 3 in conversation