SAS

Introduction to SAS PC environment. Examples using SAS for data mining, data prep and analytics.

If you are using SAS and have a large dataset where you only want ot analyze the first 100 rows, you can create a new sas dataset consisting of those first 100 observations.

Below is the PROC SQL statement that will accomplish that for you.

 The following is a basic example of a SAS program.   The program goes through the following steps.

If you get the following error in SAS:

ERROR: Expression using greater than (>) has components that are of different data types

you may be trying to evaluate dates.  The following SAS PROC SQL code would generate those errors.

If you are running SAS PC (or any form of SAS) you will likely have a table that you want to make a copy of.  Perhaps with your new copy you will want to exclude certain records or add new fields.  Below are some examples that will help you achieve these tasks.

It is good to remember that with in SAS, your default library is Work.  So any new datasets / tables that you create through your program will go to work by default unless you prefix your dataset name / table name with the name of the library you wish to operate in.

Tags:

If you are reading this it is because you have written a PROC SQL statement where you reference both a dataset that you created in an earlier step and a table that resides on an RDBMS (such as SQL Server, MySQL, Teradata, etc . .  .).

Well before you go any further I have to tell you that so far it is not possible to combine the results of a SAS data set and an DBMS table within one PROC-SQL-CREATE-TABLE-AS statement.

For example with the following code I would get an ODBC error saying that "object LIBRARY.SASDATASET1 is not an object in RDBMS ..."

In this video tutorial, you will learn how to create a new library in SAS.  Depending on your license, there are variety of liraries that can be created in SAS.  These libraries can write your datasets to a variety of files and databases.  This example illustrates how to create another library with the Default Engine type which is SAS.

See attached swf file for video tutorial.  Right click and open in new window to view the tutorial.

To export the data set you created in SAS to excel simply write the following:

PROC EXPORT DATA= LIBRARY.DATA_SET

Tags:

In this tutorial I demonstrate 3 key things. 

  1. Creating a DSN to connect to any database
  2. Connecting to a database with SAS
  3. Using PROC SQL to create a SAS dataset

The example in the tutorial uses a DSN to connect to an MS Access database.  You should know that you can connect to any database as long as you have set your DSN up correctly.  If you're connection does not work, contact a systems support rep so that he/she can set up the parameters correctly for you, or you can use one of your functioning DSNs.