Reading Tab delimited file with double quotes.

Accepted Solution Solved
Reply
Contributor
Posts: 40
Accepted Solution

Reading Tab delimited file with double quotes.

Hi,

I am trying to read a Tab delimited file with all variables in double quotes. Example "Adam Butcher"     "Analyst"     "United Kingdom Country".

I used:

Infile "C:\Data_Analytics_Companies.txt" dlm='09'x dsd missover LRECL=32760 FIRSTOBS=2;

The following infile statement reads all observations but has double quotes in the final dataset. I do not need double quotes. I have used DSD option but it does not help.  Any suggestions?

Thanks in advance

Sachin


Accepted Solutions
Solution
‎05-29-2012 03:16 PM
Contributor
Posts: 40

Re: Reading Tab delimited file with double quotes.

Thanks All.

Using Encoding="unicode" option in Infile statement did the trick.

Thanks,

Sachin

View solution in original post


All Replies
Super User
Posts: 10,538

Re: Reading Tab delimited file with double quotes.

Are you using an input statement or is this Proc Import?

Contributor
Posts: 40

Re: Reading Tab delimited file with double quotes.

Hello,

I am using Input statement. See below

Infile "C:\Users\sachin01663\Downloads\Data_Analytics_Companies.txt" dlm='09'x dsd missover LRECL=32760 FIRSTOBS=2;

Input Sr_Numb : $8. Company_name : $40. Postcode : $12. Operating_Revenue : dollar12. Year : $8.;

run;

Super Contributor
Posts: 349

Re: Reading Tab delimited file with double quotes.

Hi Sachin,

Try this...

Infile "C:\Data_Analytics_Companies.txt" dlm='09'x dsd missover LRECL=32760 FIRSTOBS=2;

informat Sr_Numb $8. ;

informat Company_name $40. ;

informat Postcode $12. ;

informat Operating_Revenue 8. ;

informat Year $8. ;

format Sr_Numb $8. ;

format Company_name $40. ;

format Postcode $12. ;

format Operating_Revenue dollar12. ;

format Year $8. ;

Input Sr_Numb Company_name  Postcode  Operating_Revenue Year ;

Thanks,

Shiva

Super User
Super User
Posts: 6,502

Re: Reading Tab delimited file with double quotes.

Works fine for me (see example code below).  Perhaps it is the use of the explicit formats on the input statement?  Try just setting the lengths of the variables using LENGTH of ATTRIB statements.  Then your input statement can just list the variable names without input formats.

filename temp temp;

data _null_;

  set sashelp.class ;

  file temp dlm='09'x dsd;

  put (_all_) (~) ;

run;

data want ;

  if 0 then set sashelp.class;

  infile temp dsd dlm='09'x ;

  input (_all_) (Smiley Happy;

run;


proc print width=min;

run;

Solution
‎05-29-2012 03:16 PM
Contributor
Posts: 40

Re: Reading Tab delimited file with double quotes.

Thanks All.

Using Encoding="unicode" option in Infile statement did the trick.

Thanks,

Sachin

☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 4391 views
  • 1 like
  • 4 in conversation