Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Handling Variable length files in SAS/WPS code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
mushreyas

New User


Joined: 18 Jul 2008
Posts: 59
Location: Bangalore

PostPosted: Fri Oct 31, 2014 11:12 am    Post subject: Handling Variable length files in SAS/WPS code
Reply with quote

Hi,

I have requirement wherein i have to handle variable length file in a SAS code to generate a CSV file. File layout is given below.

Code:
01 IRB-DATA
     02 IRB-LEN              PIC 9(4).
     02 IRB-ACCOUNT     PIC X(5).
     02 IRB-GROUP         PIC X(5).
     02 IRB-NAME-CNT    PIC 9.
     02 IRB-NAME-GRP    OCCURS 1 TO 9 TIMES
                                   DEPENDING ON IRB-NAME-CNT.
         05 IRB-TITLE       PIC X(10).
         05 IRB-FORNM     PIC X(15).
         05 IRB-SURNAME PIC X(15).
     02 IRB-MEM-FLG    PIC X(1).

Am facing issue while trying to determine the exact position of IRB-MEM-FLG as am not sure how to handle this using SAS. Any help would be appreciated?
Back to top
View user's profile Send private message

vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Fri Oct 31, 2014 2:28 pm    Post subject:
Reply with quote

Hello,
Could you post few sample records having different IRB-NAME-CNT values.

So we could be able to possibly frame a INPUT statement from it.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Oct 31, 2014 2:51 pm    Post subject:
Reply with quote

Not really sure what the problem is here, it is just elementary mathematics.

The length of the occurs group field is 40 bytes and starts in column 16, so you multiply the number of occur group fields by 40, add 16 et voila.

Perform a do loop for the count variable and then you can easily treat either the whole grouped field as an array or its components as three seperate arrays.

So, as I was a bit bored today .........................
Code:
Data OUT_01 (DROP = POS aa) ;
  ARRAY   IRB_NAME_GRPA      $40.  GRPA01 - GRPA09;
  infile  datalines;
      input   @01 IRB_LEN          4.
              @05 IRB_ACCOUNT     $5.
              @10 IRB_GROUP       $5.
              @15 IRB_NAME_CNT     1.          @;

  POS = 16;

  DO aa = 1 to IRB_NAME_CNT;
     input @POS IRB_NAME_GRPA{aa}     $40. @;
     POS + 40;   
  END;

  INPUT @POS IRB_MEM_FLG     $1.;

DATALINES;
1000ABCDEabcde11234567890ABCDEFGHIJKLMNOabcdefghijklmnoZ
2000abcdeABCDE20987654321abcdefghijklmnoABCDEFGHIJKLMNO0987654321abcdefghijklmnoABCDEFGHIJKLMNOY
;
run;

proc print noobs; run;
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Fri Oct 31, 2014 6:05 pm    Post subject:
Reply with quote

Note that your title is wrong - the record length is not variable.

All of the IRB-NAME-GRP elements may not be populated, but they do occupy positions.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Sat Nov 01, 2014 3:32 am    Post subject:
Reply with quote

Expat - clever piece of code, I learnt something.
Thank you
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Sat Nov 01, 2014 5:17 am    Post subject: Reply to: Handling Variable length files in SAS/WPS code
Reply with quote

Phry... Phil, not quite.

The stupid thing in the definition is to have put anything after the OCCURS DEPENDING ON.

If IRB-NAME-CNT is zero, it is immediately followed by IRB-MEM-FLG (IRB-NAME-GRP will have zero length).

If IRB-NAME-CNT is three, IRB-MEM-FLG will be 120 bytes after it (IRB-NAME-GRP will have a length of 120).

If that structure is written to a file, the records will be variable-length.

In the WORKING-STORAGE (or LOCAL-STORAGE) SECTION, storage will be set aside for a fixed length, but the length of the group and therefore the position of anything after that, depend on the value of IRB-NAME-CNT.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Sat Nov 01, 2014 6:02 am    Post subject:
Reply with quote

Hi Bill - thanks for the correction. Duly noted.
Back to top
View user's profile Send private message
mushreyas

New User


Joined: 18 Jul 2008
Posts: 59
Location: Bangalore

PostPosted: Sat Nov 01, 2014 9:48 pm    Post subject: Reply to: Handling Variable length files in SAS/WPS code
Reply with quote

Thanks expat.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
No new posts SQZ pipe delimited file with 1 column... Rick Silvers DFSORT/ICETOOL 2 Sun Nov 06, 2016 8:11 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us