Chapter Contents

Previous

Next
Introduction

Quick Start to Using the SAS/C Compiler

The following procedures provide the essential information you need to get started using the SAS/C Compiler under TSO, CMS, or the USS shell. To use these procedures, you need to create a simple source file such as the following:

#include <stdio.h>

main()
{
  printf("Hello World!\n");
}

Each quick-start procedure gives only basic instructions for compiling, linking, and running a C program. See the following chapters for detailed information:


TSO Quick-Start

Use this procedure to compile, link, and run a simple C program from the TSO environment.

  1. Write a small "Hello World!" program and store it in userid.QSTART.C(HELLO).

    Note:    The transient run-time library must be allocated to the DDname CTRANS or installed in the system link list before you can use the SAS/C Compiler. Your installation will probably cause it to be allocated automatically. If you encounter difficulty with the following steps, use the TSO ALLOCATE command to associate the library with the DDname CTRANS.  [cautionend]

  2. Enter the following command to compile the C source code stored in userid.QSTART.C(HELLO):
    LC370 QSTART(HELLO)

    The object code output is stored in userid.QSTART.OBJ(HELLO).

  3. Enter the following command to link the HELLO program:
    COOL QSTART(HELLO)

    The load module is stored in userid.QSTART.LOAD(HELLO).

  4. Enter the following command to run the HELLO program:
    CALL QSTART(HELLO)

    The program executes and "Hello world!" is displayed.


CMS Quick-Start

Use this procedure to compile, link, and run a simple C program from the CMS environment.

  1. Write a small "Hello world!" program and store it in a file named HELLO C.

  2. Enter the following command to compile the C source code stored in HELLO C:
    LC370 HELLO

    The object code output is stored in HELLO TEXT.

  3. Enter the following command to link the HELLO program:
    COOL HELLO (GENMOD HELLO

    The load module is stored in HELLO MODULE.

  4. Enter the following command to run the HELLO program:
    HELLO

    The program executes and "Hello world!" is displayed.


USS Quick-Start

Use this procedure to compile, link, and run a simple C program from the USS shell.

Note:    The transient library must be defined before a SAS/C program can be executed under the shell unless the library modules have been installed in the system link list. If your site does not define this library automatically, you will need to assign the transient library data set name to the environment variable ddn_CTRANS and export it before running the compiler.  [cautionend]

  1. Write a small "Hello world!" program and store it in a hierarchical file system (HFS) file named hello.c .

    Note:    In order to invoke the sascc370 command, you must include the directory where SAS/C was installed in your PATH environment variable. Probably, your site will define PATH appropriately for you when you start up the shell. If your site does not do this, contact your SAS Software Representative for C compiler products to obtain the correct directory name and add it to your PATH.  [cautionend]

  2. Enter the following command to compile and link the C source code stored in hello.c :
    sascc370 -o hello hello.c

    The object code output is stored in hello.o , and the executable output is stored in hello .

  3. Enter the following command to run the hello program:
    hello

    The program executes and "Hello world!" is displayed.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.