How to Select some random records from a File



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

How to Select some random records from a File

Postby hiiishiva » Mon Feb 11, 2013 8:38 pm

Hi All,

I am new to this JCL lang, i wanted to select some specific number of records from a file? Can anyone tell me is that possible?

Here is more detail abt my scenarios.

I am having a file with records more than 3 million, So i wanted to create a sample file with lesser records (i need to randomly pick 1000 records and put into another file).

Can you please help me with this issue?

Thanks in advance
Siva!!!
hiiishiva
 
Posts: 2
Joined: Mon Feb 11, 2013 8:02 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to Select some random records from a File

Postby enrico-sorichetti » Mon Feb 11, 2013 8:49 pm

read Your <sort> product manuals about the sampling facility.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: How to Select some random records from a File

Postby NicC » Tue Feb 12, 2013 1:52 am

Certainly JCL caanot do that as it is a JOB CONTOL language unlike other languages which are, generally, programming languages. As Enrico has stated, your sort product is probably the first place to look. If you have DFSort then look in the DFSort part of the forum and check out the links to documentation.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: How to Select some random records from a File

Postby vikkysharma » Tue Feb 12, 2013 9:46 pm

hi you can use Repro command also to copy number of records for PS file. please try below mention code.

// EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//indd DD DSN= ... (describes the input data set)
//outdd DD DSN= ... (describes the output data set)
//SYSIN DD *
REPRO -
INFILE(INDD)
OUTFILE(OUTDD)
FROMNUMBER(10)
TONUMBER(500)
/*
vikkysharma
 
Posts: 14
Joined: Sun Jan 20, 2013 4:01 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to Select some random records from a File

Postby Akatsukami » Tue Feb 12, 2013 10:04 pm

vikkysharma wrote:hi you can use Repro command also to copy number of records for PS file. please try below mention code.

// EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//indd DD DSN= ... (describes the input data set)
//outdd DD DSN= ... (describes the output data set)
//SYSIN DD *
REPRO -
INFILE(INDD)
OUTFILE(OUTDD)
FROMNUMBER(10)
TONUMBER(500)
/*

Yes indeed, Siva, please try that, then tell us how it didn't even come close to working. Of course, I may do you an injustice by supposing that you cannot fix the errors, obvious and subtle, in Vikky-kun's JCL and control cards.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: How to Select some random records from a File

Postby c62ap90 » Tue Feb 12, 2013 11:01 pm

A series of SKIP and COUNT in an IDCAMS REPRO may help you.
Just be aware of your SKIPs and COUNTs so you do not over-lap your extracts.
The STEPLAST concatenates all the sample records together.

Example...
//STEP010  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUD   DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//FILEA    DD DISP=SHR,DSN=INPUT.DATASET.HERE
//FILEB    DD DSN=OUTPUT.DATASET.#1,
//            DISP=(NEW,CATLG,DELETE),
//            ...
//SYSIN   DD *
   REPRO     -
      INFILE(FILEA) SKIP(100)    COUNT(2000)    OUTFILE(FILEB)
/*
//*-------
//STEP020  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUD   DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//FILEA    DD DISP=SHR,DSN=INPUT.DATASET.HERE
//FILEB    DD DSN=OUTPUT.DATASET.#2,
//            DISP=(NEW,CATLG,DELETE),
//            ...
//SYSIN   DD *
   REPRO     -
      INFILE(FILEA) SKIP(2100)   COUNT(1000)    OUTFILE(FILEB)
/*
//*-------
//STEP030  EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUD   DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//FILEA    DD DISP=SHR,DSN=INPUT.DATASET.HERE
//FILEB    DD DSN=OUTPUT.DATASET.#3,
//            DISP=(NEW,CATLG,DELETE),
//            ...
//SYSIN   DD *
   REPRO     -
      INFILE(FILEA) SKIP(3100)   COUNT(2000)    OUTFILE(FILEB)
/*
//*---
//*...ETC.
//*---
//STEPLAST EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUD   DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//FILEA    DD DISP=SHR,DSN=OUTPUT.DATASET.#1    F/STEP010
//         DD DISP=SHR,DSN=OUTPUT.DATASET.#2    F/STEP020
//         DD DISP=SHR,DSN=OUTPUT.DATASET.#3    F/STEP030
//            ...                               F/
//FILEB    DD DSN=OUTPUT.DATASET.SAMPLE,
//            DISP=(NEW,CATLG,DELETE),
//            ...
//SYSIN   DD *
   REPRO     -
      INFILE(FILEA) OUTFILE(FILEB)
/*
//
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 7 times

Re: How to Select some random records from a File

Postby enrico-sorichetti » Tue Feb 12, 2013 11:24 pm

while for RANDOM data You will have to write Your own program
for a patterned data extraction use, as suggested before, the SAMPLE= clause

here is the snippet

 EDIT       ENRICO.SORT.JCL(SAMPLE) - 01.00                 Columns 00001 00072
 Command ===>                                                  Scroll ===> CSR
 ****** ***************************** Top of Data ******************************
 000001 //ENRICO1  JOB NOTIFY=&SYSUID,
 000002 //             MSGLEVEL=(1,1),CLASS=A,MSGCLASS=X
 000003 //*
 000004 //ICE     EXEC PGM=SORT
 000005 //SYSOUT    DD SYSOUT=*
 000006 //SORTIN    DD *
 000007 1
 000008 2
 000009 3
 000010 4
 000011 5
 000012 6
 000013 7
 000014 8
 000015 9
 000016 10
 000017 11
 000018 12
 000019 13
 000020 14
 000021 15
 000022 16
 000023 //SORTOUT   DD SYSOUT=*
 000024 //SYSIN     DD *
 000025   OPTION COPY
 000026   OUTFIL SAMPLE=5
 ****** **************************** Bottom of Data ****************************


which gives as result

   Display  Filter  View  Print  Options  Help
 -------------------------------------------------------------------------------
 SDSF OUTPUT DISPLAY ENRICO1  JOB01604  DSID   104 LINE 0       COLUMNS 02- 81
 COMMAND INPUT ===>                                            SCROLL ===> CSR
********************************* TOP OF DATA **********************************
1
6
11
16
******************************** BOTTOM OF DATA ********************************
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: How to Select some random records from a File

Postby hiiishiva » Fri Mar 15, 2013 8:23 pm

Thanks Akatsukami - that helps what i was looking for

Thanks for all the replies
hiiishiva
 
Posts: 2
Joined: Mon Feb 11, 2013 8:02 pm
Has thanked: 0 time
Been thanked: 0 time


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post