Page 1 of 1

How to Select some random records from a File

PostPosted: Mon Feb 11, 2013 8:38 pm
by hiiishiva
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!!!

Re: How to Select some random records from a File

PostPosted: Mon Feb 11, 2013 8:49 pm
by enrico-sorichetti
read Your <sort> product manuals about the sampling facility.

Re: How to Select some random records from a File

PostPosted: Tue Feb 12, 2013 1:52 am
by NicC
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.

Re: How to Select some random records from a File

PostPosted: Tue Feb 12, 2013 9:46 pm
by vikkysharma
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)
/*

Re: How to Select some random records from a File

PostPosted: Tue Feb 12, 2013 10:04 pm
by Akatsukami
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.

Re: How to Select some random records from a File

PostPosted: Tue Feb 12, 2013 11:01 pm
by c62ap90
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)
/*
//

Re: How to Select some random records from a File

PostPosted: Tue Feb 12, 2013 11:24 pm
by enrico-sorichetti
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 ********************************

Re: How to Select some random records from a File

PostPosted: Fri Mar 15, 2013 8:23 pm
by hiiishiva
Thanks Akatsukami - that helps what i was looking for

Thanks for all the replies