Import Report Text File to Dataset

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

Import Report Text File to Dataset

Hi, Im trying to import report text file into sas Dataset, attach is the sample text file and below is my script, but I have problem with 3 field which still missing

options compress=yes;

data sample (drop=Key0 Key1);

   infile "C:\Users\Administrator\Desktop\sample.txt" delimiter = ' ' MISSOVER DSD LRECL=150 pad;

   retain no postdate valuedate ownerref relatedref furtherref aging amount side sentra date;

input key0 $84-90 @;

                if key0='REK' then input

                @103    Sentra        $4.;

input key1 $84-90 @;

                if key1='PERIOD' then input

                @94      Date        ddmmyy10.;

input

                @2      no           $5.

                @9      PostDate     ddmmyy10.

                @21     ValueDate        ddmmyy10.

    @33     OwnerRef         $42.

                @77     RelatedRef       $30.

                @107    FurtherRef       $44.

    @159    Aging            $3.   

                @169    Amount           $17.

    @189    Side             $1.;

format postdate valuedate date date9.;

if postdate ne .;

run;

3 field that still missing is Aging, Amount & Side, please help Smiley Happy thanks before

Attachment

Accepted Solutions
Solution
‎04-16-2014 02:18 AM
Super User
Posts: 7,782

Re: Import Report Text File to Dataset

Posted in reply to responcity

The positions for the three missing fields lie beyond your lrecl= number (150), so the input tries to read outside of the input data vector.

Adjust lrecl= according to the longest line (a little more does no harm)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎04-16-2014 02:18 AM
Super User
Posts: 7,782

Re: Import Report Text File to Dataset

Posted in reply to responcity

The positions for the three missing fields lie beyond your lrecl= number (150), so the input tries to read outside of the input data vector.

Adjust lrecl= according to the longest line (a little more does no harm)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 14

Re: Import Report Text File to Dataset

Posted in reply to KurtBremser

thanks for the explanation Kurt :smileygrin: really helpful,,

Occasional Contributor
Posts: 14

Re: Import Report Text File to Dataset

Posted in reply to responcity

Solved by My Boss Smiley Happy i forget to change the record limit..

🔒 This topic is solved and locked.

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

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