The SAS Output Delivery System and reporting techniques

infile error in SAS university edition

Reply
Contributor
Posts: 24

infile error in SAS university edition

Please help me with this: I am getting below error while submitting this code. I have a txt file with delimeter "|" and One coloum Names has names like Suraj, Singhal James, Garg I want to import this data without proc import data. data New; infile '/C:/temp/test23.csv' dlm="|" firstobs=5 ; input name $ M_Name $ Type $ Month $ Year $ MetCount AppCount PercentMet; run; NOTE: Invalid data for MetCount in line 14 1-170. NOTE: Invalid data for AppCount in line 15 1-171. NOTE: Invalid data for PercentMet in line 16 1-195. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+--- NOTE: Invalid data errors for file ''/C:/temp/test23.csv'' occurred outside the printed range. NOTE: Increase available buffer lines with the INFILE n= option. Thanks!

Valued Guide
Posts: 554

Re: infile error in SAS university edition

I don't think we can answer this without seeing the actual data...

Super User
Posts: 9,548

Re: infile error in SAS university edition

Please folllow my advice from your other post.

USE THE {I} ICON TO POST LOG OR INFILE TEXT!

You can see what the main posting window is doing to your text:


suraj wrote:

Please help me with this: I am getting below error while submitting this code. I have a txt file with delimeter "|" and One coloum Names has names like Suraj, Singhal James, Garg I want to import this data without proc import data. data New; infile '/C:/temp/test23.csv' dlm="|" firstobs=5 ; input name $ M_Name $ Type $ Month $ Year $ MetCount AppCount PercentMet; run; NOTE: Invalid data for MetCount in line 14 1-170. NOTE: Invalid data for AppCount in line 15 1-171. NOTE: Invalid data for PercentMet in line 16 1-195. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+--- NOTE: Invalid data errors for file ''/C:/temp/test23.csv'' occurred outside the printed range. NOTE: Increase available buffer lines with the INFILE n= option. Thanks!


Post the relevant sample of your infile (up to line 16 ff).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 7,844

Re: infile error in SAS university edition

Take the time to tell SAS how to define your variables. It will make it much easier for you.  You probably also want to use the DSD and TRUNCOVER options on your INFILE statement so that SAS will properly locate missing vlaues and also not try to find missing data by going to the next line of the input file.

 

So something like this:

data New;
  infile '/C:/temp/test23.csv' dlm="|" firstobs=5 dsd truncover ;
  length name $100 M_Name $50 Type $8 Month $10 Year $4 
       MetCount 8 AppCount 8 PercentMet 8
  ;
  input name M_Name Type Month Year MetCount AppCount PercentMet; 
run;

PS Do you really have a directory named 'C:' in the root directory of your Unix filesystem?

Contributor
Posts: 24

Re: infile error in SAS university edition

Hello @Tom,

 

Thanks a lot for help

 

data New;
infile '/temp/new_test1.bat' dlm="|" firstobs=5 dsd truncover ;
length name $100 m_name $100  inputMonth $100 inputYear $100 MetCount 8 AppCount 8 PercentMet 8
;
input name m_name inputMonth inputYear MetCount AppCount PercentMet;
run;

 

I used above code still I am not able to get data now it is not cosidering the delimeter reads like

obs      Name               m_name

 1 SURAJ, SINGHAL|JA  MES, GARG|

 

still getting warning notes

 

NOTE: Invalid data for PercentMet in line 9 165-167.

 

Please help!

 

Thanks

Super User
Super User
Posts: 7,844

Re: infile error in SAS university edition

It should not have put | into the values of the variables if you used | as the delimiter on the INFILE statement. The only way that could happen would be if the | occured inside of quotes in the data lines.  

Post some sample data lines (redact any sensitive information.)  Make sure to use the Insert Code icon in the forum editor. Looks like {i} on the tool bar at the top of the edit box.  This will preserve the formatting of the lines.

 

I simple way to get some sample lines is to run a quick SAS data step.  So this will print the first 10 lines in your file to the SAS log. And if any of the lines contain unprintable characters it will also show the ASCII codes (in HEX) for those lines.

data _null_;
  infile '/temp/new_test1.bat' obs=10;
  input;
  list;
run;
Ask a Question
Discussion stats
  • 5 replies
  • 156 views
  • 0 likes
  • 4 in conversation