BookmarkSubscribeRSS Feed
helloSAS
Obsidian | Level 7

 

 

Here is the sample code for file creation. When I use DSD option in the file statement, it is putting double quotes around field A in the output file whereas without DSD option it gives an extra space for missing fields. Any one has a solution?

 

fieldval|newfield|new| |1

 

"fieldval|newfield"|new||1

 

 Its putting double quotes because your delimiter is a pipe and your Field A also has a pipe.  


options missing='';
data one;
a='fieldval|newfield';
b='new';
c='';
d='1';
run;

filename outfile "/uhome/snoone/test.txt" ;

data _null_;
set one;

file outfile DELIMITER='|' dropover dsd lrecl=1000;
put a
b
c
d;
run;

 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, what is the question here, you seem to have your answer?

" Its putting double quotes because your delimiter is a pipe and your Field A also has a pipe.  "

If your data contains the delimiter, then it has to quote the string otherwise delimeters will get messed up.  Sort your input dataset out:

data one;
  a1='fieldval';

  a2='newfield';
  b='new';
  c='';
  d='1';
run;

 

And the problem will go away.

 

Edit: Alternatively change your delimiter.  The point about delimited files is that the delimiter only appears between data items.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 1278 views
  • 0 likes
  • 2 in conversation