BookmarkSubscribeRSS Feed
HeidiDT
Quartz | Level 8

I am using the File Reader transformation in DI Studio to import a pipe delimited text file. Some of the fields contain quotes, and I ant to remove the dsd option from the generated code so that the quotes are not seen as delimiters. The problem is I can't find the option in the transformation to do this! Any suggestions?

1 REPLY 1
Patrick
Opal | Level 21

DSD is what will remove the quotes.

filename mydata temp;
data _null_;
  file mydata;
  put '1|"ABC"||3';
  put '2||"XYZ"|4';
run;

data demo;
  infile mydata missover dsd dlm='|';
  input vara varb :$3. varc :$3. vard;
run;

proc print data=demo;
run;

Patrick_0-1652186707644.png

I don't have DI "at hand" to test it but I believe the file reader should allow you a definition that will generate code as in above infile statement. 

You can also always add additional option in the text field of the file reader. Whatever you write there will just get added to the infile statement.

 

I've used in the past this field also for some "code ingestion" like...

;
input @:
_infile_=compress(_infile_,'"');

Such code would get added right after the INFILE statement but prior to the INPUT statement and though would remove double quotes before you start mapping the input buffer to variables.

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
  • 476 views
  • 0 likes
  • 2 in conversation