---
title: "Explained SAS Macro Here’s Tutorial"
description: "Simple SAS macro that filter input file and write into output data set. Explained all steps to execute a macro using JCL in mainframe"
url: https://srinimf.com/2012/05/19/mainframe-with-sas/
date: 2012-05-19
modified: 2026-10-05
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2012/05/desk-office-pen-ruler.jpg?fit=1880%2C1253&ssl=1
categories: ["SAS"]
tags: ["SAS Mainframe", "SAS tips and tricks"]
type: post
lang: en
---

# Explained SAS Macro Here’s Tutorial

SAS skills with Mainframe you can find many jobs. SAS (Statistical Analysis System) is used in **Mainframe** for creating reports. For Mainframe professionals, learning and working on SAS is not a difficult task. The tutorial would explain how to run [SAS macro](https://srinimf.com/2014/06/09/sas-mainframe-program/) using Mainframe JCL.

---

> The online SAS course for mainframe, without wasting your time, you can learn here. [Click and buy the course](http://www.training-courses-online.com/?a_aid=4ef40d011a3fb).

SAS is a macro level programming language. We can write programs with SAS. In the MVS environment, we can use both On-line and [Batch JCL](https://srinimf.com/2012/05/16/db2-bind-options/) to execute SAS macros.

**SAS with MVS (Batch);**

**[Sample JCL](https://srinimf.com/2015/10/16/jcl-to-sort-few-fields-in-an-input-dataset/) to run SAS:**

```
//SASSTP1  EXEC SAS6 
//INPUT1     DD   DSN=Inputfile,DISP=SHR 
//OUTPUT1    DD   DSN=Outputfile,DISP=OLD 
//SYSIN  DD   *  DATA  WORK.M;  
 INFILE INPUT1;  
 INPUT        
 FILELD1  $1-10               
 FILELD2 $11-20;  
 IF FIELD1= ‘22GCPMGGCAP’;  
 RUN; 
/*
```

The above is best example, where it reads [input file](https://srinimf.com/2018/03/28/sas-splitting-input-dataset-into-multiple-files/) and filters for matching record and write into [output file](https://srinimf.com/2016/08/26/how-to-write-master-file-popular-program-in-cobol/).

After executes RUN, it writes records into o/p file. Just grab my [favourite book](http://astore.amazon.com/mainframesrin-20/detail/1555447945)to start your SAS learning.

Related Posts

- [How to Start Your First SAS Macro](https://srinimf.com/2014/06/09/sas-mainframe-program/)DateJune 9, 2014
- [SAS course contents you need](https://srinimf.com/2014/04/21/mainframe-sas-course/)DateApril 21, 2014
- [The Easy Way Removing Duplicates in SAS](https://srinimf.com/2018/03/11/sas-eliminate-duplicates/)DateMarch 11, 2018

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2012%2F05%2F19%2Fmainframe-with-sas%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2012%2F05%2Fdesk-office-pen-ruler.jpg%3Ffit%3D1200%252C800%26ssl%3D1&description=Explained%20SAS%20Macro%20Here%27s%20Tutorial)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2012/05/19/mainframe-with-sas/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2012/05/19/mainframe-with-sas/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2012/05/19/mainframe-with-sas/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2012/05/19/mainframe-with-sas/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20Explained%20SAS%20Macro%20Here%27s%20Tutorial&body=https%3A%2F%2Fsrinimf.com%2F2012%2F05%2F19%2Fmainframe-with-sas%2F&share=email)
-

### Like this:

Like Loading…
