BookmarkSubscribeRSS Feed
iluvsas
Calcite | Level 5

I have a test.dat cobol file in the below format and need to read this file and convert to a sas

dataset.

The first row is the header and the last row is the trailer record in the test.dat file.
I need to exclude the header and trailer records when I read and convert the file to a sas dataset.

Any thoughts to read these files in SAS in batch mode as I have 7 files of the same format.


Test.dat
--------

101111STR1 EXTRACT FILE       2012040120120402
15666+12345+4174.99YJohn Doe            1234
15667+12346+6179.99YJohn Doe2           1235
103455STR1 EXTRACT FILE       2012040120120402000000+1234.99

The cobol file layout for the fields is as below:

roll-type    pic X(01)
pno          pic X(04)
p1-num-s  pic X(01)
p1-num    pic X(05)
a1-s        pic X(01)
a1           pic 9(4).99
code       pic X(01)
name      pic X(20)
code2     pic x(04)


1 REPLY 1
RMP
SAS Employee RMP
SAS Employee

something like this would work.

data cobol(drop=rectype);

  infile cards truncover;

   input rectype $200. @;

   if index(rectype,'EXTRACT FILE') then return;

   input rolltype $1 pno $4 p1_num_s $1 p1_num $5;

output;

datalines;

101111STR1 EXTRACT FILE       2012040120120402

15666+12345+4174.99YJohn Doe            1234

15667+12346+6179.99YJohn Doe2           1235

103455STR1 EXTRACT FILE       2012040120120402000000+1234.99

;

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
  • 1 reply
  • 847 views
  • 0 likes
  • 2 in conversation