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

Distinct values in a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Fri Jul 23, 2010 7:55 am
Reply with quote

Dear Expert,

I have a file with 5 columns say
EMPID EMPNAME SALARY DESIGNATION DEPARTMENT
101 AAAAAAA 100000 ENGINEER IT
102 BBBBBBB 100000 ADMIN ADMIN
103 CCCCCC 100000 MANAGER IT
104 DDDDDD 100000 ADMIN ADMIN
105 EEEEEEEE 100000 TEAM LEAD IT
106 FFFFFFFFF 100000 ENGINEER IT
107 GGGGGG 100000 ENGINEER IT
108 HHHHHHH 100000 MANAGER IT
109 IIIIIIIIIII 100000 TEAM LEAD IT
110 KKKKKKK 100000 HR HR

Now I would like to know
1) Distinct values in DESIGNATION column
By SQL, I can achieve this using
SELECT DISTINCT DESIGNATION FROM EMPLOYEE.

2) Distinct values in DESIGNATION column and its count.
By SQL, I can achieve this using
SELECT DISTINCT DESIGNATION, count(*) FROM EMPLOYEE group by DESIGNATION.

I would like to achieve the same results using DFSORT for the above file.
Please suggest me an idea.
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 213
Location: Cochin/Kerala/India

PostPosted: Fri Jul 23, 2010 8:46 am
Reply with quote

Hi MKK,
Try the below code
[/code] SORT FIELDS=(14,8,CH,A) -----> Designation
INREC FIELDS=(1,25,26:C'001')
SUM FIELDS=(26,3,ZD)
OUTREC FIELDS=(14,8,26,3)
Code:
Back to top
View user's profile Send private message
ssmukul

New User


Joined: 22 Jan 2008
Posts: 19
Location: India

PostPosted: Fri Jul 23, 2010 10:51 am
Reply with quote

Hi MKK,

As I don't know the starting position and length of DESIGNATION field, I have used below input to get the results as you required.
Code:
//SORTIN DD * 
101 AAA ENG IT
102 BBB ENG IT
103 CCC ADM IT
104 DDD MNG IT
105 EEE ENG IT
106 FFF ADM IT
107 GGG MNG IT

For distinct designation I have used below sort card,
Code:
//SYSIN DD *           
  SORT FIELDS=(9,3,CH,A)
  SUM FIELDS=NONE       
  OUTREC FIELDS=(1:9,3)

and the O/P is as
Code:
ADM
ENG
MNG

For distinct designation and its count,
Code:
//SYSIN DD *                           
  SORT FIELDS=(9,3,CH,A)               
    OUTFIL REMOVECC,NODETAIL,           
     SECTIONS=(9,3,                     
     TRAILER3=(9,3,COUNT=(EDIT=(IIT))))

and the O/P is as
Code:
ADM  2
ENG  3
MNG  2

Please amend the sort card according to your requirement.
Thanks.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Fri Jul 23, 2010 7:41 pm
Reply with quote

Alternatively, you can also use below. I assumed your designation field starts from 24th position and is 10 bytes.

Code:
//STEP1    EXEC  PGM=ICETOOL                                 
//TOOLMSG DD SYSOUT=*                                     
//DFSMSG  DD SYSOUT=*                                     
//IN      DD *                                           
101 AAAAAAA     100000 ENGINEER   IT                     
102 BBBBBBB     100000 ADMIN      ADMIN                   
103 CCCCCC      100000 MANAGER    IT                     
104 DDDDDD      100000 ADMIN      ADMIN                   
105 EEEEEEEE    100000 TEAM LEAD  IT                     
106 FFFFFFFFF   100000 ENGINEER   IT                     
107 GGGGGG      100000 ENGINEER   IT                     
108 HHHHHHH     100000 MANAGER    IT                     
109 IIIIIIIIIII 100000 TEAM LEAD  IT                     
110 KKKKKKK     100000 HR         HR                     
//OUT      DD SYSOUT=*                                   
//TOOLIN DD *                                             
 OCCUR FROM(IN) LIST(OUT) ON(24,10,CH) BETWEEN(2) -       
   ON(VALCNT,N08) NOHEADER                               
/*                                                       


Thanks,
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
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
Search our Forums:

Back to Top