BookmarkSubscribeRSS Feed
mlopezvalentin
Calcite | Level 5

Good afternoon.

I need to read a fixed text file (mainframe data; length 522).  This file has characters, numbers and symbols (e.g. squares/blocks).    I have read in SAS (v 9.3) the same file directly from mainframe without problems (below SAS code) .

 

FILENAME CCREP FTP " ' mainframe file name' " USER='XXXXX' PROMPT

LRECL=412 RECFM=FB HOST='XXXX.XXXX.XX.XX';

 

This time I received a text file with 11 new variables.  I have added the new variables into my SAS program, but I am encountering problems reading the text file (below SAS code).

 

FILENAME CCREP "File location and name.txt";

Data REPORTA; INFILE CCREP LRECL=522 RECFM=FB;

 

DATA acf800.REPORTA;
INFILE CCREP;

INPUT

@1 GRNTYPE $EBCDIC1. @2 DISPO $EBCDIC1....;

 

 

I have received the following errors and notes:

-Invalid value for the RECFM option.

 

-0 records were read from the infile CCREP

several notes  for:

Invalid data for X variable in line 1 3-7 (for example)

-Lost Card

-Invalid errors for file CCREP occurred outside the printed range

-Increase available buffer lines with the INFILE n=option

 

Please, let me know if additional information is required.  Thank you in advanced for the assistance.  

2 REPLIES 2
TomKari
Onyx | Level 15

Here's a quick code snippet that might help you figure out the problem:

 

FILENAME CCREP "some file.txt";

data _null_;
	infile CCREP;
	input;
	file log;
	put _infile_;

	if _n_ = 5 then
		stop;
run;

First of all, you should get some diagnostics on the characteristics of the dataset. Second, it will print the contents of the first five records, so you can get some idea of if the lengths make sense and if the contents are correct. From there, you (and we, if necessary) can try to figure out what's up.

 

Tom

ballardw
Super User

Instead of describing error message you would be better off to copy from the log the entire data step and all the messages and then paste them into a code box opened using the forum's {I} or "running man" icon. The code box is important to retain formatting as many error messages, including the invalid data type, include diagnostics that the message windows here will reformat.

 

Then we  won't have to ask a whole bunch of leading questions about stuff that should be obvious from your code.

 

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 753 views
  • 0 likes
  • 3 in conversation