sort jcl to copy selected columns

Sort JCL: Quickly Copy Selected Columns

By Nicole Clark
AD

Ever found yourself drowning in an ocean of data, needing to cherry-pick specific columns from your Sort JCL to create a new subset? You're not alone. In this guide, we'll delve into the world of Sort JCL, focusing on how to copy selected columns, making your data management tasks smoother and more efficient.

First, let's understand that Sort JCL, or Job Control Language, is a structured programming language used to process data, usually on mainframe computers. Now, onto the main attractions: copying selected columns from your data.

Understanding the SORT Component

A key component in your JCL arsenal, SORT allows you to rearrange, eliminate, and even duplicate records based on specific criteria. It's perfect for our task at hand - isolating certain columns.

AD
How to Sort by Column in Excel and Keep Rows Together (4 Easy Ways) - ExcelDemy
How to Sort by Column in Excel and Keep Rows Together (4 Easy Ways) - ExcelDemy
How to merge and combine Excel spreadsheets into one
How to merge and combine Excel spreadsheets into one
How to Sort Multiple Columns in Excel (5 Quick Methods) - ExcelDemy
How to Sort Multiple Columns in Excel (5 Quick Methods) - ExcelDemy

Before we dive into the specifics, let's clarify a misconception. SORT doesn't 'copy' columns in the traditional sense. Instead, it pulls out the required columns and creates a new output dataset with those selected columns only.

The SELECT Statement

The backbone of our operation, the SELECT statement in SORT tells the system which columns to include and which to exclude. Here's the basic syntax:

How to Sort Column by Value in Excel (7 Easy Ways) - ExcelDemy
How to Sort Column by Value in Excel (7 Easy Ways) - ExcelDemy
How to Sort Columns in Excel Without Mixing Data (6 Methods) - ExcelDemy
How to Sort Columns in Excel Without Mixing Data (6 Methods) - ExcelDemy
How to Sort Two Columns to Match in Excel (2 Simple Methods) - ExcelDemy
How to Sort Two Columns to Match in Excel (2 Simple Methods) - ExcelDemy

SELECT column1, column2, ...

You simply list the columns you want to keep, separated by commas. Easy, right?

AD

Control Breaks and Unmatched Records

Control breaks allow you to group records together based on common fields. This is particularly useful when you're not just copying columns but creating a new dataset with those columns that shares the same values in certain fields.

How to Copy and paste excluding hidden columns or rows in Excel
How to Copy and paste excluding hidden columns or rows in Excel
How to Copy and Paste a Column in Excel
How to Copy and Paste a Column in Excel
How to Sort Rows by Column in Excel (4 Easy Methods) - ExcelDemy
How to Sort Rows by Column in Excel (4 Easy Methods) - ExcelDemy
Macro to Copy Specific Columns from One Worksheet to Another in Excel (6 Methods) - ExcelDemy
Macro to Copy Specific Columns from One Worksheet to Another in Excel (6 Methods) - ExcelDemy
How to Use Columns Formula in Excel
How to Use Columns Formula in Excel
Excel Sort by Column or Row One or Multiple Sort by Cell Color Font Color Customize Sort
Excel Sort by Column or Row One or Multiple Sort by Cell Color Font Color Customize Sort

On the other hand, unmatched records deal with records that don't have corresponding records for comparison. You can choose to including them in your new dataset or not with the SELECT statement. Here's how you might do that:

SELECT (column1, column2, ...) IF (control break condition) ELSE (unmatched records action)

AD

Let's say you want to include only the unique values in 'column1'. You can achieve this with:

How to Sort Multiple Columns Alphabetically in Excel (4 Methods) - ExcelDemy
How to Sort Multiple Columns Alphabetically in Excel (4 Methods) - ExcelDemy
SQL - Select all columns that satisfy a specific condition
SQL - Select all columns that satisfy a specific condition
Copy a VLOOKUP Formula Down a Column
Copy a VLOOKUP Formula Down a Column
How to Sort a Column Using VBA in Excel (4 Methods) - ExcelDemy
How to Sort a Column Using VBA in Excel (4 Methods) - ExcelDemy
Shortcut Select Whole Column Fast
Shortcut Select Whole Column Fast
How to Sort in Excel Rows or Columns Avoid Sort Problems
How to Sort in Excel Rows or Columns Avoid Sort Problems
an excel spreadsheet showing the number and type of columns in each column, including
an excel spreadsheet showing the number and type of columns in each column, including
How to Insert Columns into Google Docs
How to Insert Columns into Google Docs
How to read Multiple Columns from CSV File in Python? With Source Code
How to read Multiple Columns from CSV File in Python? With Source Code
What is a Column in Excel
What is a Column in Excel
Excel Selection Shortcuts: 5 Essential Cell, Row & Column Shortcuts
Excel Selection Shortcuts: 5 Essential Cell, Row & Column Shortcuts
50K views · 3.6K reactions | Are you using this Excel feature? 🤔 Learn how to organize data in Excel using Text to Column. ✨ #excel #exceltips #exceltricks #spreadsheets #corporate #accounting #workhacks #finance | Easilyexcel
50K views · 3.6K reactions | Are you using this Excel feature? 🤔 Learn how to organize data in Excel using Text to Column. ✨ #excel #exceltips #exceltricks #spreadsheets #corporate #accounting #workhacks #finance | Easilyexcel
Shortcuts to Insert Column in Excel (4 Easiest Ways)
Shortcuts to Insert Column in Excel (4 Easiest Ways)
How to Create a Column Chart with Multiple Series and Small Multiple?
How to Create a Column Chart with Multiple Series and Small Multiple?

SELECT (column1, column2) IF output NOT EQUALS INFILE or SELECT (unique column2) IF output NOT EQUALS INFILE

Building Your SORT JCL

Now that we've covered the core aspects of selecting columns, let's put it all together in a SORT JCL.

AD

Here's a simple example:

```jcl SORT FIELDS=(2,1,A,LEN=10) , (3,1,CH,A), INCLUDE/CONTROL/SELECT = (FIELD/SELECT/LEN=10) , FIELDS/OUTPUT/(COL/SELECT,LEN=10) ```

In this example, we're sorting on fields 2 and 3, control breaks are based on the first 10 characters of field 2, and the output file includes field 2 but excludes field 3.

Ghost Records

Ghost records are a powerful tool in SORT's arsenal, allowing you to add or modify records in your output. You can use them to add new columns with fixed values, insert blank records, or update existing records.

For instance, you might add a new column with a fixed value of '1' like this:

SORT ... GHOST/WANT=(FIELD/A,GHOST,LEN=1,UC='1'),...

DOC Files: )

A DOC file, or Document file, in SORT is a control file containing statements for sort processing. It's an efficient way to organize your SORT operations, especially when you're running complex jobs.

Here's a simple example of a DOC file that copies selected columns:

DOC SORT ... GHOST/WANT=(FIELD/A,GHOST,LEN=1,UC='1'),... SELECT=(FIELD/A,STOP), ... ... END SORT

See? Just a few lines to achieve your goal.

Animating Your SORT JCL

Animating your JCL involves creating views or reports based on your data using tools like JCL Dynamo or COPII. Once you've used SORT to extract your required columns, these tools can help you visualize your data more effectively.

So, there you have it. Copying selected columns with Sort JCL doesn't have to be a daunting task. With a bit of understanding, you can whip up a SORT job to extract just the data you need, like a pro.

Happy sorting!

AD