Mainframe Sas Online Training 01 (1)

Embed Size (px)

DESCRIPTION

SAS

Citation preview

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    1/27

    Introduction to SAS and Basic Concepts

    Statistical Analysis System

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    2/27SAS Presentation | | 7/27/142

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    3/27SAS Presentation | | 7/27/143

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    4/27SAS Presentation | | 7/27/145

    Turning Data into Information

    The process of delivering meaningfl information is typicallydistri!ted as

    follo"s#

    80% data-related

    $ access

    $ scr!

    $ transform

    $ manage

    $ store and retrieve

    20% analysis

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    5/27SAS Presentation | | 7/27/14%

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    6/27SAS Presentation | | 7/27/147

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    7/27SAS Presentation | | 7/27/14&

    Basic concepts of SAS

    'vervie"

    SAS Programs

    SAS (i!raries)eferencing SAS files

    SAS data Sets

    *aria!le Attri!tes

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    8/27SAS Presentation | | 7/27/14+

    Oerie!

    To program effectively sing SAS, yo need to nderstand !asicconcepts a!ot SAS programsand the SAS files that they process- .n

    particlar, yo need to !e familiar "ith SAS data sets-

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    9/27SAS Presentation | | 7/27/141

    SAS "rogram

    0o can se SAS programs to access, manage, analye, or present yordata-

    (ets !egin !y looing at a simple SAS program-

    DATA SAMPLE;INPUT NAME $10.;

    DATALINES;

    ANIL

    ARUN;

    RUN;

    PROC PRINT DATA=SAMPLE;

    RUN;

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    10/27SAS Presentation | | 7/27/1411

    Components of SAS "rograms # Sample code

    'r sample SAS program contains t"o steps# a ATA stepand a P)' step-

    DATA SAMPLE;

    INPUT NAME $10.;DATALINES;

    ANIL

    ARUN;

    RUN;PROC PRINT DATA=SAMPLE;

    RUN;

    Continued$

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    11/27SAS Presentation | | 7/27/1412

    Components of SAS "rograms # DATA ST"& "'OC ST"

    T(ese t!o types of steps& alone or com)ined& form most SAS programs*

    Continued$

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    12/27SAS Presentation | | 7/27/1413

    DATA steps typically create or modify SAS data sets- They can also !e sed to prodcecstom designed reports- 6or eample, yo can se ATA steps to

    pt yor data into a SAS data set

    compte vales

    chec for and correct errors in yor data

    prodce ne" SAS data sets !y s!setting, merging, and pdating eisting data sets-

    "'OC +procedure, steps are pre8"ritten rotines that ena!le yo to analye and

    process the data in a SAS data set and to present the data in the form of a report- P)'

    steps sometimes create ne" SAS data sets that contain the reslts of the procedre-

    P)' steps can list, sort, and smmarie data- 6or eample, yo can se P)' steps

    to

    create a report that lists the data

    prodce descriptive statistics

    create a smmary report

    prodce plots and charts-

    Components of SAS "rograms

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    13/27SAS Presentation | | 7/27/1414

    C(aracteristics of SAS "rograms

    9et let:s loo at the individal statements in or sample program- SAS programs consistof SAS statements- A SAS statement has t"o important characteristics#

    .t sally !egins "ith a SAS ey!ord-

    .t al"ays ends "ith a semicolon

    DATA SAMPLE; ---- SAS Data Step creating DataetINPUT NAME $10.;

    DATALINES;

    ANIL

    ARUN;

    RUN;

    PROC PRINT DATA=SAMPLE; -- SAS PROC tep ! Printing DATA

    RUN;

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    14/27SAS Presentation | | 7/27/1415

    .ayout for SAS "rograms

    SAS statements are in free format- This means that

    they can !egin and end any"here on a line

    one statement can contine over several lines

    several statements can !e on a line-;lans or special characters separate

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    15/27SAS Presentation | | 7/27/141%

    "rocessing SAS "rograms

    >hen yo s!mit a SAS program, SAS !egins reading the statements and checingthem for errors- ATA and P)' statements signal the !eginning of a ne" step- >hen

    SAS enconters a s!se=ent ATA, P)', or )?9 statement @for ATA steps and

    most procedres or a B?.T statement @for some procedres, SAS stops reading

    statements and eectes the previos step in the program- .n or sample program, each

    step ends "ith a )?9 statement-

    DATA SAMPLE; ---- SAS Data Step creating Dataet

    INPUT NAME $10.;

    DATALINES;

    ANIL

    ARUN;

    RUN;

    PROC PRINT DATA=SAMPLE; -- SAS PROC tep ! Printing DATA

    RUN;

    /oteThe !eginning of a ne" step @ATA or P)' implies the end of the previos

    step- Thogh the )?9 statement is not al"ays re=ired !et"een steps in a

    SAS program, sing it can mae the SAS program easier to read and de!g,

    and it maes the SAS log easier to read-

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    16/27SAS Presentation | | 7/27/1417

    .og 1essages

    Cach time a step is eected, SAS generates a log of the processing activities and the reslts of the

    processing- The SAS log collects messages a!ot the processing of SAS programs and a!ot any errors

    that occr- >hen SAS processes or sample program, yo see the log messages sho"n !elo"- 9otice that

    yo get separate sets of messages for each step in the program-

    SAS .og

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    17/27SAS Presentation | | 7/27/141&

    SAS .og and SAS .i)raries

    Cvery SAS file is stored in a SAS li)rary, "hich is a collection of SAS files- ASAS data li!rary is the highest level of organiation for information "ithin SAS-

    6or eample, in the >indo"s and ?9.D environments, a li!rary is typically a

    grop of SAS files in the same folder or directory-

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    18/27SAS Presentation | | 7/27/141+

    SAS .i)raries

    The ta!le !elo" smmaries the implementation of SAS li!raries in variosoperating environments-

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    19/27

    SAS Presentation | | 7/27/142

    'eferencing SAS iles

    To reference a SAS file, yo se a t"o8level name,libref.filename- .n the t"o8level name, libref is the name forthe SAS li!rary that contains the file, and filename is the name of the

    file itself- A period separates the li!ref and filename-

    To reference temporary SAS files, yo specify the defalt li!ref 3or,

    a period, and the filename- Alternatively, yo can simply se a one8

    level name @the filename only to reference a file in a temporary SAS

    li!rary- )eferencing a SAS file in any li!rary e4cept 3or indicates

    that the SAS file is stored permanently-

    SAS data set names can !e 1 to 32 characters long, mst !egin "itha letter @A-E, either ppercase or lo"ercase or an nderscore @F,

    and can contine "ith any com!ination of nm!ers, letters, or

    nderscores-

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    20/27

    SAS Presentation | | 7/27/1421

    SAS Data Sets

    6or many of the data processing tass that yo perform "ithSAS, yo access data in the form of a SAS data set andse SAS programs to analye, manage, or present the data-onceptally, a SAS data set is a file that consists of t"o

    parts# a descriptor portion and a data portion-

    The descriptor portion of a SAS data set contains information a!ot the data set-

    The data portion of a SAS data set is a collection of data vales that are arranged in arectanglar ta!le-

    O)serations in the data set correspond to ro"s or data lines in a ra" data file

    or in an eternal data!ase- An o!servation is the information a!ot each o!Gect in a SASdata set-

    5aria)les in the data set correspond to colmns in a ra" data file or in an eternaldata!ase-

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    21/27

    SAS Presentation | | 7/27/1422

    5aria)le Attri)utes

    .n addition to general information a!ot the data set, the descriptorportion contains information a!ot the attri!tes of each varia!le in

    the data set- The attri!te information incldes the

    varia!le:s name,

    type,

    length, format,

    informat, and

    la!el-

    /ame

    Cach varia!le has a name that conforms to SAS naming conventions- *aria!le namesfollo" eactly the same rles as SAS data set names- (ie data set names, varia!le

    names

    can !e 1 to 32 characters long

    mst !egin "ith a letter @A-E, either ppercase or lo"ercase or an nderscore @F

    can contine "ith any com!ination of nm!ers, letters, or nderscores- Continued$

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    22/27

    SAS Presentation | | 7/27/1423

    5aria)le Attri)utes

    9ame continedH

    Type

    A varia!le:s type is either c(aracter or numeric- haracter varia!les, sch as 9ame @sho"n !elo", can contain any alues-

    9meric varia!les, sch as Policy and Total @sho"n !elo", can contain only numeric alues @the digits throgh +, I, 8, -, and C for

    scientific notation-

    Continued$

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    23/27

    SAS Presentation | | 7/27/1424

    .engt(

    A varia!le:s lengt( @the nm!er of !ytes

    sed to store it is related to its type- haracter varia!les can !e p to 62&77 )ytes long- .n the eample !elo", 9ame

    has a length of 2 characters and ses 2 !ytes of storage-

    All nmeric varia!les have a defalt length of 8- 9meric vales @no matter ho"

    many digits they contain are stored as floating8point nm!ers in & !ytes of storage,

    nless yo specify a different length-

    5aria)le Attri)utes

    Continued$

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    24/27

    SAS Presentation | | 7/27/1425

    5aria)le Attri)utes

    ormat 6ormats are varia!le attri!tes that affect the "ay data vales are "ritten- SAS

    soft"are offers a variety of character, nmeric, and date and time formats- 0o

    can also create and store yor o"n formats- To "rite vales ot sing a

    particlar form, yo select the appropriate format-

    Continued$

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    25/27

    SAS Presentation | | 7/27/142%

    5aria)le Attri)utes

    Informat

    ormats "rite vales out !y sing some particlar form "hereas informats read data vales in

    certain forms into standard SAS vales- .nformats determine ho" data vales are read into a SAS

    data set- 0o must se informats to read nmeric vales that contain letters or other special

    characters-

    Continued$

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    26/27

    SAS Presentation | | 7/27/1427

    5aria)le Attri)utes

    .a)elA varia!le can have a la)el, "hich consists of descriptive

    tet p to 25% characters long- ;y defalt, many reports

    identify varia!les !y their names- 0o might "ant to display

    more descriptive information a!ot the varia!le !yassigning a la!el to the varia!le-

  • 5/21/2018 Mainframe Sas Online Training 01 (1)

    27/27