+ All Categories
Home > Documents > SAS Basic Procs

SAS Basic Procs

Date post: 30-May-2018
Category:
Upload: maythri
View: 224 times
Download: 0 times
Share this document with a friend

of 27

Transcript
  • 8/14/2019 SAS Basic Procs

    1/27

    1

    Basic SAS Procedures

    Greg Jenkins

  • 8/14/2019 SAS Basic Procs

    2/27

    2

    Overview

    SAS procedures are functions that generallytake data in either from a data set, or

    specified options, and then output someinformation.

    Thats pretty vague, but we will look atsome basic SAS procedures for examples.

    Coding and options are similar for mostprocedures.

  • 8/14/2019 SAS Basic Procs

    3/27

    3

    Syntax Common to Most Procedures

    Most procedures have the following generalsyntax:

    proc something ;

  • 8/14/2019 SAS Basic Procs

    4/27

    4

    Syntax Common to Most Procedures

    The data= statement specifies the data setthe procedure will use, if the procedurerequires an input data set(some dont). If

    the data= statement is left out the last dataset created is used.

    Where clause allows subsetting of data.

    by statement allows the processing of theprocedure separately for each level of theby variable, you need to sort the inputdata set by the by variable.

  • 8/14/2019 SAS Basic Procs

    5/27

    5

    Syntax Common to Most Procedures

    The label and format statements workexactly the same as in the data step. Theformats and labels are removed from the

    data set after the procedure is ended. Some procedures are interactive and start

    processing when the proc statement issubmitted. Others require a run;

    statement at the end of the procedure codeto start processing, or start processing byreaching the beginning of another SASstatement.

  • 8/14/2019 SAS Basic Procs

    6/27

    6

    Syntax Common to Most Procedures

    Most procedures will end on their own after

    all the procedure code is submitted, but for

    interactive procedures, such as: proc

    gplot, gchart, sql, reg, and some others; a

    quit; statement must be used to end the

    procedure unless code related to another

    procedure, data step, SAS option, etc. isreached.

  • 8/14/2019 SAS Basic Procs

    7/27

    7

    Types of Procedures

    There are lots of them, but well just discuss

    a few groups, and few procedures within

    those groups.

    First, well look at base SAS procedures.

    The first procedures well talk about are

    report writing related: print, printto,tabulate, and report.

  • 8/14/2019 SAS Basic Procs

    8/27

    8

    Proc Print

    Used to output the contents of a SAS dataset.

    Basic syntax:

    proc print ;

    run;

  • 8/14/2019 SAS Basic Procs

    9/27

    9

    Proc Print

    label statement tells SAS whether youwant the labels or variable names ofvariables used as column headers.

    The var statement lets you list thevariables in the data set you want printed.

    By default observations(rows) in the datasetare identified by the row number, the id

    statement allows you change this to a set ofvariables(dont include these variables inthe var statement unless you want themprinted out twice ).

  • 8/14/2019 SAS Basic Procs

    10/27

    10

    Other Report Writing Procedures

    proc printto allows output, and log files to

    be redirected to a specified text file.

    Proc report & tabulate are fancier

    versions of proc print, they can also do

    some minor calculations.

  • 8/14/2019 SAS Basic Procs

    11/27

    11

    Basic Statistics Procedures

    The next group of basic procedures well

    talk about are procedures that do basic

    statistics, like simple frequency

    (contingency) tables, univariate statistics,

    etc.

    These procedures are: proc univariate,means, freq, rank, and corr.

  • 8/14/2019 SAS Basic Procs

    12/27

    12

    Proc Univariate

    Calculates basic statistics for one variable,

    mean, median, etc., also does tests.

    proc univariate ;

  • 8/14/2019 SAS Basic Procs

    13/27

    13

    Proc Univariate

    If no variables are specified in the var optionthe procedure will run on all the variables in thedata set specified.

    This procedure outputs a wide variety ofstatistics and can also create output datasetscontaining these statistics.

    Proc univariate will conduct t-tests, and tests for

    non-normality(if the normal option is used).

    It will also produce histograms, probabilityplots,

  • 8/14/2019 SAS Basic Procs

    14/27

    14

    Proc Means

    Basically a scaled down version of proc

    univariate, does not conduct tests, fewer

    statistics, etc.

    Its advantage over proc univariate is that it

    processes quicker, and is easier to work

    with if the aim is to get an output data setthat contains statistics of more than one

    variable. proc univariate does not do this.

  • 8/14/2019 SAS Basic Procs

    15/27

    15

    Proc Freq

    Basically creates frequency, and

    contingency tables.

    proc freq ;

  • 8/14/2019 SAS Basic Procs

    16/27

    16

    Proc Freq

    In the table statement if you want to create a

    contingency table of one or more variables

    join the variables by an asterisk(*).

    proc freq;

    table gender*smoke;

    run;

  • 8/14/2019 SAS Basic Procs

    17/27

    17

    Proc Freq

    Proc freq will do testing, approximate, and

    exact.

    Outputs measures of association,

    agreement, and odds ratios.

    Also has several output data sets.

  • 8/14/2019 SAS Basic Procs

    18/27

    18

    Other Basic Statistics Procedures

    Proc rank, will output a data set of ranks

    based on variables from an input dataset and

    various options.

    Proc corr, outputs correlation type

    information, for comparisons of two

    continuous variables, also does non-parametric comparisons.

  • 8/14/2019 SAS Basic Procs

    19/27

    19

    Utility Procedures

    These procedures are utilities, they are for

    the most part work with data sets, they: sort,

    edit, copy, etc. They do not generally

    produce output.

    Some of the procedures we have already

    seen are: proc format, proc import(using theimport wizard), proc sql(well talk about

    later), and proc contents.

  • 8/14/2019 SAS Basic Procs

    20/27

    20

    Brief Overview: Utility Procedures

    Proc copy copies SAS datasets, catalogs.

    Proc datasets works on datasets in a

    library.

    Proc compare compares two datasets.

    Proc append concatenates data sets.

    Proc transpose transposes data(well talk

    about this later)

  • 8/14/2019 SAS Basic Procs

    21/27

    21

    Categories of Other Procedures

    SAS/STAT statistical procedures, learnabout these for the most part in a statistics

    classes. SAS/ACCESS procedures for importing

    data from other sources.

    SAS/OR procedures related to operationsresearch(proc netwflow for networkproblems, etc.)

  • 8/14/2019 SAS Basic Procs

    22/27

    22

    Categories of Other Procedures

    SAS/ETS statistical procedures, time

    series tools

    SAS/FSP data entry tools

    SAS/GIS tools for GIS(Geographic

    Information Systems) data

    SAS/GRAPH graphics

    SAS/IML Interactive matrix language

  • 8/14/2019 SAS Basic Procs

    23/27

    23

    Categories of Other Procedures

    SAS/EIS data warehousing tools

    SAS/QC quality control procedures, like

    proc capability(nice procedure for normal-

    probability plots, etc.)

    And many, many more

  • 8/14/2019 SAS Basic Procs

    24/27

    24

    Output from Procedures

    Output for SAS procedures are generallysent to the output window(interactive SAS)or .lst file(Line Mode SAS), however someprocedures have no output or send the

    output to the log window, or .log file, A relatively new improvement to SAS is

    ODS(Output Delivery System), improvesthe way output is delivered from

    procedures. ODS still doesnt deliver great output but

    it can be useful, as well, it can create .pdf,.html, .rtf, and many other file types.

  • 8/14/2019 SAS Basic Procs

    25/27

    25

    GUIs for Procedures

    As mentioned earlier there are somegraphical user interfaces for procedures, onethat is very useful is the SAS/SQL GUI.

    The SQL GUI can be found be selectingtools then Query.

    Another GUI is for proc import, this is theimport data wizard that youve seen.

    SAS/ASSIST is a GUI for some otherprocedures.

  • 8/14/2019 SAS Basic Procs

    26/27

  • 8/14/2019 SAS Basic Procs

    27/27

    27

    Help on the Help!

    Its a long running joke(although not a good

    one!) that you need a SAS manual to read a

    SAS manual.

    Theres a good description of SASs syntax

    convention in the SAS OnlineDoc Version 8,

    which I didnt copy because of copyrightreasons!


Recommended