reading raw file with multiple occurances

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 142
Accepted Solution

reading raw file with multiple occurances

[ Edited ]

Hi!  I am having problems reading in a text file.  I have the attached layout that gives me the position, length and possible occurances.  My file is reading in fine until i come accross a variable with multiple possible occurances.  I'm not sure how to set up the code.

 

See attached document for the txt layout.  The text file reads in fine until "ItemfromDate" ...POsition start @75 Value length 8 and 45 possible occurances.  SAS is not reading this any other or other text following 'itemfrom date', so I'm guessing this must be where my error starts (with the multiple occurance variables)  Now, this filed is not populated and Im not using any of the occurances, but I want to include it as a placeholder (same goes with many other fields on this list) so I am basically multiplying the length*occurances for many of the variables for example  @75 ItemFromDate $360.

 

Can you take a look at my code and see where my error might be?

data asthma.OPcrg_FY14;
infile 'O:\Clark\asthma1_out.txt' truncover;
input 
@1PatientID $19.
@20Sex $1.
@21 BirthDate $8.
@29 ClaimID $30.
@59 AdmitDate $8.
@67 DischargeDate $8.
@75 ItemFromDate $360.
@435 ItemtoDate $360.
@795 DischargeStatus $2.
@797 TypeOfBill $4.
@801 PlaceofService $2.
@803 ProviderType $1.
@804 ICDVersionQualifier $1.
@805 AdmitDiagnosis $8.
@813 PrincipalDiagnosis $8.
@821 SecondaryDiagnosis2 $8.
@828 SecondaryDiagnosis3 $8.
@835 SecondaryDiagnosis4 $8.
@842 SecondaryDiagnosis5 $8.
@849 SecondaryDiagnosis6 $8.
@856 SecondaryDiagnosis7 $8.
@863 SecondaryDiagnosis8 $8.
@870 SecondaryDiagnosis9 $8.
@877 SecondaryDiagnosis10 $8.
@884 SecondaryDiagnosis11 $8.
@891 SecondaryDiagnosis12 $8.
@898 SecondaryDiagnosis13 $8.
@905 SecondaryDiagnosis14 $8.
@912 SecondaryDiagnosis15 $8.
@919 SecondaryDiagnosis16 $8.
@926 SecondaryDiagnosis17 $8.
@933 SecondaryDiagnosis18 $8.
@941 SecondaryDiagnosis19 $8.
@948 SecondaryDiagnosis20 $8.
@1213 ExternalCauseofInjury $96.
@1309 ReasonForVisitDiagnosis $24.
@1333 Procedure1 $7.
@1340 Procedure2 $7.
@1347 Procedure3 $7.
@1354 Procedure4 $7.
@1361 Procedure5 $7.
@1368 Procedure6 $7.
@1375 Procedure7 $7.
@1382 Procedure8 $7.
@1389 Procedure9 $7.
@1396 Procedure10 $7.
@1403 Procedure11 $7.
@1410 Procedure12 $7.
@1417 Procedure13 $7.
@1424 Procedure14 $7.
@1431 Procedure15 $7.
@1438 Procedure16 $7.
@1445 Procedure17 $7.
@1452 Procedure18 $7.
@1459 Procedure19 $7.
@1466 Procedure20 $7.

on and on until  
@109534 ItemDinCodeDisConditions $13500;
run;

Accepted Solutions
Solution
‎01-15-2016 03:53 PM
Super User
Posts: 11,343

Re: reading raw file with multiple occurances

The issue is the length of a record that SAS can read. The option LRECL controls that and is defaulting to something considerably shorter than you need.

 

Try adding:

LRECL=150K

to your INFILE statement.

View solution in original post


All Replies
Solution
‎01-15-2016 03:53 PM
Super User
Posts: 11,343

Re: reading raw file with multiple occurances

The issue is the length of a record that SAS can read. The option LRECL controls that and is defaulting to something considerably shorter than you need.

 

Try adding:

LRECL=150K

to your INFILE statement.

Frequent Contributor
Posts: 142

Re: reading raw file with multiple occurances

@ballardw I wish I had posted this sooner!!! Instead of spending days trying to figure this out.  THANK YOU!!!!!

Super User
Posts: 11,343

Re: reading raw file with multiple occurances

But now it will stick with you that the line length is something to consider when reading OR writing external files.
Super User
Posts: 19,855

Re: reading raw file with multiple occurances

On the infile statement try setting the LRECL option.

 

infile 'O:\Clark\asthma1_out.txt' LRECL=200000 truncover;

 

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 440 views
  • 2 likes
  • 3 in conversation