DATA Step, Macro, Functions and more

Spaces added to between PIPE delimiter when writing to a flat file.

Reply
Regular Contributor
Posts: 246

Spaces added to between PIPE delimiter when writing to a flat file.

I have tried the answer on this topic:

https://communities.sas.com/t5/General-SAS-Programming/Spaces-added-to-between-PIPE-delimiter-when-w...

 

But then i get 4 quotes around my values like """"value""""|"""""column2"""""|"""""""""|

 

proc sql;
create view work.W2MFNVH as
select
(strip(put(VEQUNR3,30.))) as Connection_GlobalID length = 30
format = $30.,
VSTREET as Street,
VHOUSEN1 as HouseNumber1,
VHOUSEN2 as HouseNumber2,
VCITY as Municipality,
(compress(ZGPSCOORY)) as XCoord length = 20
format = $20.
label = 'Aansl e gps coordinaat x',
(compress(ZGPSCOORX)) as YCoord length = 20
format = $20.
label = 'Aansl e gps coordinaat y'
from &SYSLAST
;
quit;

%let SYSLAST = work.W2MFNVH;
options missing='';
data _null_;
set &SYSLAST;
attrib Connection_GlobalID length = $30
format = $30.;
attrib Street length = $60
format = $60.;
attrib HouseNumber1 length = $10
format = $10.;
attrib HouseNumber2 length = $10
format = $10.;
attrib Municipality length = $40
format = $40.;
attrib XCoord length = $20
format = $20.;
attrib YCoord length = $20
format = $20.;
quote='"';
file "&aa_path.reload.coordinatesdn.&ts..del" dlm='|' DSD;

if ( _n_ = 1 ) then
do;
put
"Connection_GlobalID|Street|HouseNumber1|HouseNumber2|Municipality|XCoord|YCoord";
end;
put
quote +(-1) Connection_GlobalID +(-1) quote
quote +(-1) Street +(-1) quote
quote +(-1) HouseNumber1 +(-1) quote
quote +(-1) HouseNumber2 +(-1) quote
quote +(-1) Municipality +(-1) quote
quote +(-1) XCoord +(-1) quote
quote +(-1) YCoord +(-1) quote
;

run;

Super User
Super User
Posts: 9,599

Re: Spaces added to between PIPE delimiter when writing to a flat file.

[ Edited ]

Please use a code window, its the {i} above the post area.  Why are you using &SYSLAST throughout and manually setting it at one point, this is not the way to program in SAS.

As for your question:

options missing='';
data _null_; 
  set work.w2mfnvh; 
  file "&aa_path.reload.coordinatesdn.&ts..del" dlm='|' dsd;
  if _n_=1 then put "Connection_GlobalID|Street|HouseNumber1|HouseNumber2|Municipality|XCoord|YCoord";
  put connection_globalid street housenumber1 housenumber2 municipality xcoord ycoord;
run;

What does the above not do?  The output file generated there is fine and compliant delimited text - file extension fine!.  You only need quotes if the data contains the delimiter, which if it does then change the delimiter.

Regular Contributor
Posts: 246

Re: Spaces added to between PIPE delimiter when writing to a flat file.

I'm using DI studio, therefor it uses syslast. The above makes sure that i don't have blanks between 2 pipes. But it generates extra quotes (4 double quotes). I have to follow some guidelines like the format has to be .del and string characters needs to have double quotes.
Ask a Question
Discussion stats
  • 2 replies
  • 59 views
  • 0 likes
  • 2 in conversation