SAS Notes

Compiled by : Wilson Suraweera @ CGHR
Contents
Random Numbers in SAS
Data Sub-setting
Method  for Select a Random Sample
Missing values replacement with Means of the respective Variables
Logistic Regression with SAS
SAS made easy using Proc SQL
SAS PROC SQL procedure to access external ODBC data sources
External Resources
Macro Seminar - UCLA
Logistic regression
          Some Interesting SAS SQL Examples
SAS Dinosaur - Old and New way of SAS progrming
Paul Dicman's Web Page for SAS- This little old discusses SAS 8, but useful
Global Statements Dictionary - Alphabatical listing and Description of SAS Key words

 

         

  1. Using Proc SQL

    SAS implements a comprehensive SQL language facility for data manipulation purposes. Using PROC SQL, the SAS structured query language procedure to insert, delete, modify and retrieve information from SAS data tables

    SAS does not allow SQL statements to be used in the DATA step. However, SAS provides PROC SQL which allows operations on SAS datasets with SQL. The SAS terms dataset, observation, and variable respectively correspond to the SQL terms table, row, and column.

    The syntax of PROC SQL is:
     

     PROC SQL < option(s)> ;
         ALTER alter-statement;
         CREATE create-statement;
         DELETE delete-statement;
         DESCRIBE describe-statement;
         DROP drop-statement;
         INSERT insert statement;
         RESET < option < option &gt...> ;
         SELECT select-statement;
         UPDATE update-statement;
         VALIDATE validate-statement;
    

     

    ALTER changes the attributes of columns or adds or drops columns
    CREATE creates tables
    DELETE removes rows from a table
    DESCRIBE display a view definition
    DROP deletes the table
    INSERT inserts a new row into the table
    RESET allows options to be changed during execution
    SELECT retrives data and outputs results
    UPDATE modifies columns in existing rows
    VALIDATE checks a query-expression for syntactic accuracy.

    Note that the DELETE statement has exactly the same function as the
    DELETE statement used in the DATA step. However, DROP in PROC SQL
    will delete the entire table(dataset) rather the columns(variables).
     

    Some of options which may be useful: INOBS=n restricts the number of rows processed from a source
    NUMBER|NONUMBER includes a column with the row number
    PRINT|NOPRINT turns printing for SELECT statements on or off
     

     

Learn More  : http://help.pop.psu.edu/help-by-software-package/sas/sql-with-sas

Back to Top