SAS Data Set and Programming Basics - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

SAS Data Set and Programming Basics

Description:

A library reference name (libref) can be assigned using the libname statement: ... Character. Creating/Modifying SAS Data Sets ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 12
Provided by: jamesb156
Category:

less

Transcript and Presenter's Notes

Title: SAS Data Set and Programming Basics


1
SAS Data Set and Programming Basics
  • STT 305

2
SAS Programs
  • SAS Programs consist of three major components
  • Global statements
  • Procedures
  • Data steps

3
SAS Programs
Global Statements
Procedures
Data Step
4
Notes
  • Data steps and procedures are made up of one or
    more statements.
  • All statements end with a semicolon.
  • This is the only restriction, SAS programs are
    otherwise free-forme.g. the following are
    equivalent
  • proc sort datatotalrev
  • by origin destination
  • run
  • proc sort datatotalrevby origin
    destinationrun

5
Notes
  • The run statement is optional (only the final one
    is required).
  • The run statement indicates to SAS that the
    procedure or data step is complete.
  • Starting a new data step or procedure is also
    taken by SAS as an indication that the previous
    one is complete (nesting of data steps and/or
    procedures is not allowed).
  • Using the run statement is generally good
    practice

6
SAS Data Set Basics
  • SAS data set reference
  • Two levels libref.data-set
  • libref is the SAS library (work library is
    default if libref is omitted)
  • data-set is the name of the SAS data set
  • SAS naming conventions
  • Names can be up to 32 characters in length
  • Not case sensitive
  • Must begin with a letter or underscore
  • Contain only letters, numbers or underscores
  • Applies to data sets, variables and libraries,
    but libraries are limited to 8 characters.

7
SAS Data Libraries
  • A SAS data library is a directory on your
    computer where SAS data sets are stored or will
    be stored.
  • A library reference name (libref) can be assigned
    using the libname statement
  • libname libref path-specification
  • The libref must follow naming conventions and the
    path specified must exist.

8
SAS Data Set Basics
  • SAS data sets consist of two portions
  • Descriptor portion
  • Data portion
  • Descriptor portion
  • Contains various status information
  • Can be viewed with PROC CONTENTS

9
The Contents Procedure
  • To view the descriptor portion of a data set
  • proc contents datalibref.filename
  • run
  • To view data set listing for a particular
    library
  • proc contents datalibref._all_ nods
  • run

Keyword to display all data sets in library
Suppress descriptor portion
10
SAS Data Set Basics
  • Data portion
  • Contains variable names and values
  • Can be viewed with PROC PRINT or via the
    explorer.
  • SAS variables and values are of two types
  • Numeric
  • Character

11
Creating/Modifying SAS Data Sets
  • The data step can be used to create a SAS data
    set using an existing SAS data set
  • data output-data-set
  • set input-data-set
  • SAS statements
  • run
Write a Comment
User Comments (0)
About PowerShow.com