Statistics for Economics and Business Introduction to Sas

Embed Size (px)

Citation preview

  • 8/8/2019 Statistics for Economics and Business Introduction to Sas

    1/2

    STATISTICS FOR ECONOMICS AND BUSINESSINTRODUCTION TO SAS:

    STATISTICS FOR ECONOMICS AND BUSINESS INTRODUCTION TO SAS

    Introduction to SAS:

    Introduction to SAS SAS is a powerful statistical software designed to support Business

    Intelligence. SAS communicates with you, and you communicate with SAS through a system ofWindows. Main programming windows There are three main programming widows. EDITOR:

    In the editor window you write your SAS programs, i.e., the procedures you want to apply toyour data. SAS procedures are a collection of statements. LOG: The log window gives to you

    information about programs you submitted to SAS. In particular, you should always have a lookto this window where you can find the statements you submitted. In this windows three kind of

    messages are displayed: NOTES (blue): give to you information about your elaboration.ERRORS (red): tell you that some error occurred while elaborating your program, and that this

    error can not be managed by SAS. Your program statements have to be changed in order toremove the problem. WARNINGS (green): tell you that your program may contain some errors.

    Nevertheless, SAS understood which error occurred and tells you how it managed the erroritself. You have to check if the correction made by SAS is satisfactory. OUTPUT: The output

    window displays the required output.

    Introduction to SAS:

    Introduction to SAS Navigation windows Two more windows are available to have an easier

    access to your input and to your output. EXPLORER: In this window you find information about

    SAS libraries (see later). From this window you can open SAS data set . RESULT: This windowpermits to you to quickly navigate your output. Moreover, you can use this window to obtain theoutput in a format which can be easily exported in Excel and in Word (see later).

    Introduction to SAS:

    Introduction to SAS Below a description of the main steps of a SAS section is reported

    Introduction to SAS Accessing SAS datasets:

    Introduction to SAS Accessing SAS datasets SAS only elaborates data matrices in a SASformat. Managing SAS datasets. To access an already existing SAS dataset, you have to indicate

    to SAS where (which directory on yr PC) it is located. Directories on your PC can not be directlyaccessed from SAS. A SAS library is a name assigned (during a session) to one directory in

    your PC. Hence, when your session starts, you have to specify which directories in yr PC(possibly) contain data you are going to use, by declaring the libraries. Assigning a library The

    simplest way to assign a library consists in clicking on the New Library button on the main menu

  • 8/8/2019 Statistics for Economics and Business Introduction to Sas

    2/2

    Introduction to SAS Permanent and work libraries:

    Introduction to SAS Permanent and work libraries Managing SAS datasets. A data set in a

    given directory can be accessed by specifying its name and its directory: libname.datanameWork and permanent SAS datasets. A data set created during one SAS session will by default bestored in a work library, which will be erased at the end of the session. If you want to save your

    SAS dataset you have to specify the library (directory on yr PC) where you want yr data to besaved. Hence A data set referred to as dataname Will be lost at the end of the session A data set

    referred to as libname.dataname Will be saved at the end of the session

    Introduction to SAS Importing External data :

    Introduction to SAS Importing External data Importing data from external sources It is possible

    to import data in other formats. At this aim you can use the Import Wizard. From any SASwindow, you can open the File menu in the main menu bar and you can select Import Data. The

    imported dataset can be saved in the work library or in a permanent library

    Introduction to SAS SAS programs:

    Introduction to SAS SAS programs SAS programs are constituted by two fundamental steps.DATA Step: This step is used to manipulate data, transform variables and, also, to modify the

    structure of datasets. PROC Step: This step is used to elaborate SAS dataset, i.e. to analyze data,to create reports, to obtain graphs. As it was said before, SAS programs must be written in the

    Editor Window. Data and Proc Steps are collection of statements. The first statement contains astarting declaration key (DATA or PROC) indicating whether the procedure consists in a data or

    in a proc step. Also the other statements start with an identification key [in blue] identifying theelaboration required. ALL SAS statement must end with a semicolon ; . Each data or proc step

    ends with a run; statement, indicating that no more elaboration are required in a particularstep of analysis. If a word in a statement is emphasized in red this means that the statement is

    wrong. Comments may be inserted, and have to be preceded by a /* and followed by a */ .Comments are emphasized in /* green */. A quoted text, Text (within quotation marks), is

    emphasized in violet. Take care: Quotation marks must always be closed.