SAS Examples: Proc SQL

Last updated:

WIP Alert This is a work in progress. Current information is correct but more content may be added in the future.

Select top N rows

proc sql outobs=100;
    select *
    from namespace.my_database;

Case when

proc sql;
    select case 
        when <condition> then <some value>
        when <other condition> then <other value>
        else <yet another value>
    end as <field_alias>
    from <namespace>.<table_name>;

Create an index for an existing table

For indexes with a single column, the index name must be the same as the column name

proc sql;
    create index <index_name>
        on <namespace>.<table_name>(<column_name>);

Dialogue & Discussion