SAS Base Programming - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

SAS Base Programming

Description:

SAS Base Programming Temporary vs. Permanent SAS Data Sets SAS Data Library When you invoke SAS, you automatically have access to temporary and a permanent SAS data ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 10
Provided by: Josh101
Category:
Tags: sas | base | print | proc | programming

less

Transcript and Presenter's Notes

Title: SAS Base Programming


1
SAS Base Programming
  • Temporary vs. Permanent SAS Data Sets

2
SAS Data Library
  • When you invoke SAS, you automatically have
    access to temporary and a permanent SAS data
    library.

work temporary library
sasuser permanent library
libref permanent library
You can create and access your own permanent
libraries
3
Temporary SAS data set
  • By default, SAS data set you create is stored in
    the work library.
  • The SAS data set in the work library exists only
    during the current job or session, and
    automatically erased when you exit SAS.

DATA distance Miles 26.22 Kilomeers
1.61Miles PROC PRINT data distance RUN PRO
C PRINT data work.distance RUN
4
Assigning a libref
  • You can use the LIBNAME statement to assign a
    libref to a SAS data library.

General form of the LIBNAME statement
LIBNAME libref SAS-data-library ltoptionsgt
Example
Iibname mylib\\mySAS\summer07\data
5
Naming a libref
  • Rules for naming a libref
  • must be 8 characters or less
  • must begin with a letter or underscore
  • remaining characters are letters, numbers, or
    underscores.

Example
____OK____
____not OK____
mylib_07
07_mylib
_07mylib
mylib07
mylib07
mylib 07
6
Two-level SAS filenames
  • Every SAS file has a two-level name

libref.filename
Second name (filename) refers to the file in the
library
First name (libref) refers to the library
7
Lets try!
  • Create a Library named mylib
  • libname mylib 'C\Documents and Settings\xxxx'
  • Permanent SAS Data Set
  • DATA mylib.distance
  • Miles 26.22
  • Kilometers 1.61Miles
  • PROC PRINT data mylib.distance
  • RUN
  • direct reference
  • PROC PRINT data 'C\Documents and
    Settings\xxxx\distance'
  • RUN

8
Browsing a SAS data library
  • Use the _ALL_ keyword to list all the SAS files
    in the library and the NODS option to suppress
    the descriptor portions of the data sets.

General form of the NODS option
PROC CONTENTS DATA libref._ALL_ NODS
NODS must be used in conjunction with the keyword
_ALL_
9
Browsing a SAS data set
  • To explore the description of a SAS data set,
    specify the data set name in the DATAoption

PROC CONTENTS DATA libref.SAS-data-set-name
Example
PROC CONTENTS data mylib._all_ nods RUN PROC
CONTENTS data mylib.distance RUN
Write a Comment
User Comments (0)
About PowerShow.com