IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SAS - splitting up of data using a comma delimited file.


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Sat Jun 19, 2010 7:23 am
Reply with quote

Hi,

I have a comma delimited input file in the following format,
Code:
OP2,NORMALSTRAP: OP2MODLM,4,15,4,15,0,0,0,0,0,0,0,0       
OP2,NORMALSTRAP: OP2PRODP,4,14,4,14,0,0,0,0,0,0,0,0       
OP2,NORMALSTRAP: OP2WAREP,4,14,4,14,0,0,0,0,0,0,0,0       
OP2,PICT COPY: ABDDEV AGSDTEST,16,14,0,0,0,0,16,14,0,0,0,0
OP2,PICT COPY: ABDDEV APPDATAP,19,66,0,0,0,0,19,66,0,0,0,0

Using the below SAS code, i am extracting only the data i need,
Code:
//SASSTEP EXEC  SAS                                     
//IFILE   DD DISP=SHR,DSN=HXSULL.TEST(SMR)             
//OUTFILE DD DSN=HXSULL.BOBT1.MFSTORE.UL,               
//         DISP=(NEW,CATLG,DELETE),                     
//         UNIT=TEST,                                   
//         SPACE=(CYL,(10,5),RLSE),                     
//         DCB=(RECFM=FB,LRECL=70,BLKSIZE=0)           
//SYSIN  DD *                                           
OPTIONS NOCENTER;                                       
DATA INFILE;                                           
INFILE IFILE DLM=',' ;                                 
 INPUT A $ B :$30. C  D ;                               
PROC PRINT DATA=INFILE;                                 
 TITLE2 'DATA FILE';                                   
                                                       
 DATA OFILE;                                           
    SET INFILE;                                         
    FILE OUTFILE;                                       
PUT @1  A                                               
    @5  B                                               
    @40 C                                               
    @50 D   
    ;       


Output of the above SAS code,
Code:

The SAS System                                             
DATA FILE                                                 
                                                           
Obs     A                 B                  C     D       
                                                           
 1     OP2    NORMALSTRAP: OP2MODLM          4    15       
 2     OP2    NORMALSTRAP: OP2PRODP          4    14       
 3     OP2    NORMALSTRAP: OP2WAREP          4    14       
 4     OP2    PICT COPY: ABDDEV AGSDTEST    16    14       
 5     OP2    PICT COPY: ABDDEV APPDATAP    19    66       

Now, i want to split up column B into more columns like the following, help me i don't know how to proceed.
Code:
OBS     A          B         C             D          E     F
 1     OP2    NORMALSTRAP    OP2MODLM                 4    15
 2     OP2    NORMALSTRAP    OP2PRODP                 4    14
 3     OP2    NORMALSTRAP    OP2WAREP                 4    14
 4     OP2    PICT COPY      ABDDEV     AGSDTEST     16    14
 5     OP2    PICT COPY      ABDDEV     APPDATAP     19    66
 


Thank You in advance,
Sushanth
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Sat Jun 19, 2010 11:22 am
Reply with quote

Code:
INFILE IFILE DLM=',:' ;
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Sat Jun 19, 2010 8:38 pm
Reply with quote

Thank You Very Much Peter for that,

Using the SAS SCAN function, i got what i wanted.

Code:
OPTIONS NOCENTER;                             
DATA INFILE;                                   
INFILE IFILE DLM=',:' ;                       
 INPUT A $ B :$30. C :$30. D E ;               
 FW=SCAN(C, 1,' '); **FIRST WORD IN A STRING; 
 SW=SCAN(C, 2,' '); **LAST WORD IN A STRING;   
                                               
PROC PRINT DATA=INFILE;                       
 TITLE2 'DATA FILE';                           
                                               
 DATA OFILE;                                   
    SET INFILE;                               
    FILE OUTFILE;                             
PUT @1  A                                     
    @5  B                                     
    @40 C                                     
    @50 D                                     
    ;                                         


Output
Code:
The SAS System                                                                 
DATA FILE                                                                       
                                                                               
Obs     A          B         C                   D     E       FW          SW   
                                                                               
 1     OP2    NORMALSTRAP    OP2MODLM            4    15    OP2MODLM           
 2     OP2    NORMALSTRAP    OP2PRODP            4    14    OP2PRODP           
 3     OP2    NORMALSTRAP    OP2WAREP            4    14    OP2WAREP           
 4     OP2    PICT COPY      ABDDEV AGSDTEST    16    14    ABDDEV      AGSDTEST
 5     OP2    PICT COPY      ABDDEV APPDATAP    19    66    ABDDEV      APPDATAP


Thank You,
Sushanth
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
Search our Forums:

Back to Top