BookmarkSubscribeRSS Feed
suraj
Obsidian | Level 7

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!

5 REPLIES 5
ChrisBrooks
Ammonite | Level 13

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

Kurt_Bremser
Super User

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).

Tom
Super User Tom
Super User

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?

suraj
Obsidian | Level 7

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

Tom
Super User Tom
Super User

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 1014 views
  • 0 likes
  • 4 in conversation