1 Chapter 2: Working with Data in a Project 2.1 Introduction to Tabular Data 2.2 Accessing Local...

Preview:

Citation preview

1

Chapter 2: Working with Data in a Project

2.1 Introduction to Tabular Data

2.2 Accessing Local Data

2.3 Accessing Remote Data

2.4 Importing Text Files

2.5 Editing Tables in the Data Grid (Self-Study)

2

Chapter 2: Working with Data in a Project

2.1 Introduction to Tabular Data2.1 Introduction to Tabular Data

2.2 Accessing Local Data

2.3 Accessing Remote Data

2.4 Importing Text Files

2.5 Editing Tables in the Data Grid (Self-Study)

3

Objectives State the definition of a SAS table. State how data is stored in a SAS table.

4

IntroductionTo begin work with SAS Enterprise Guide, you

1. create a project

2. add data to the project

3. run tasks against the data.

Additionally, you can

4. customize results

5. automate the process.

5

Microsoft Excel Microsoft Excel spreadsheetsspreadsheets

dBASE filesdBASE files

HTML tablesHTML tablesODBC-ODBC-compliant datacompliant data

OLE DB OLE DB provider’s filesprovider’s files

Microsoft Microsoft AccessAccess tablestables

Fixed-width Fixed-width and delimited and delimited

text filestext files

Common Data FormatsSAS Enterprise Guide can read and use data from a variety of different formats.

SAS tablesSAS tables

6

SAS Data TablesA SAS data table is a rectangular table of rows and columns.

Columns (variables)

Rows (observations)

7

SAS Data TablesAll columns must have a name, type, and length.

Names can be1 to 32

characters long.

8

A column’s type is either character or numeric. The type plays a role in determining the length.

Character values are1 to 32,767 characters

(bytes) long.

Numeric values are 8 bytesof floating point storage: Numeric Currency Date (days from 01JAN1960) Time (seconds from midnight)

SAS Data Tables

9

SAS Data TablesA format is used to control how values are displayed. Formats do not affect how values are stored.

Format: MMDDYYWidth: 10Stored value: 15060

Format: DOLLARWidth: 10Decimal Places: 0Stored value: 76806

10

Formats

11

SAS Data Table Properties

12

Missing ValuesIf a data value is not present for a column in a particular row, it is considered missing. A missing character value is displayed as a blank. A missing numeric value is displayed as a period or dot.

..

.

13

Chapter 2: Working with Data in a Project

2.1 Introduction to Tabular Data

2.2 Accessing Local Data2.2 Accessing Local Data

2.3 Accessing Remote Data

2.4 Importing Text Files

2.5 Editing Tables in the Data Grid (Self-Study)

14

Objectives Add a local Excel spreadsheet to the project. View the properties of the data.

15

Software File AttributesThe software file

contains metadata.

The software file does not contain

metadata.

16

Open Options for Data Sources Other than SAS

Enables SAS Enterprise Guide to read data directly

Provides a detailed import process to create

a new SAS table

17

ScenarioAdd an Excel spreadsheet to the project to provide a list of supplier names and addresses.

18

This demonstration illustrates how to add a local Excel spreadsheet to the project.

Adding a Local Excel Spreadsheet to the Project

19

Chapter 2: Working with Data in a Project

2.1 Introduction to Tabular Data

2.2 Accessing Local Data

2.3 Accessing Remote Data2.3 Accessing Remote Data

2.4 Importing Text Files

2.5 Editing Tables in the Data Grid (Self-Study)

20

Objectives Identify remote data sources. Access a remote server. Add remote data to a project.

21

Transparent Access to Remote Data

Local User

UNIX

sas

OracleDB2

z/OSMainframe

Oracle

sas

sas WindowsServer

sas

22

Opening Data from a SAS Server

The Libraries icon enables access to predefined

folders containing SAS or DBMS data sources.

The Files icon enables access to the

directories available on the server.

23

The Server List window also provides an organized view of all of your files and data sources.

Accessing Remote Data

Server List

24

After you add a data source to a project, the table automatically opens in the Data Grid.

Accessing Remote Data

25

Accessing Remote DataTo prevent a table from opening automatically when added to a project, disable the following option by selecting Tools Options.

26

ScenarioAdd a remote DB2 table to the project. The table contains information on the transactions for products and stores.

27

This demonstration illustrates how to add a remote data table to the project.

Adding a Remote Tableto a Project

28

Chapter 2: Working with Data in a Project

2.1 Introduction to Tabular Data

2.2 Accessing Local Data

2.3 Accessing Remote Data

2.4 Importing Text Files2.4 Importing Text Files

2.5 Editing Tables in the Data Grid (Self-Study)

29

Objectives Use the Import Data task to import a text file

into a project as a SAS table.

30

Import Data TaskThe Import Data task can be used to convert a file into a customized SAS data table.

31

Import Data TaskTo your computer, a text file is only strings of characters. SAS Enterprise Guide requires that the data be arranged into rows and columns (observations and variables).

32

Import Data TaskThe Import Data task enables you to tell SAS Enterprise Guide the following: where each column is located in the text file which columns to read in the name of each column if the first row contains column headings the type of data in each column

– character– numeric (currency, date, time)

how much storage space to allocate how to display the data values

33

Import Data TaskThe Import Data task stores the data as a SAS table.

34

ScenarioLLB Importers has a fixed-width text file named Orders.

The file contains orders received this quarter from delicatessens. Create a SAS table named Orders.sas7bdat that has the following characteristics: does not contain the customer order number assigns a descriptive label to the product identification

number displays the selling price and revenue as a currency

35

ScenarioOrders.txt Orders.sas7bdat

36

This demonstration illustrates the functionality available when you use the Import Data task to read data.

Adding Data from a Fixed-width Text File

37

Complete the Chapter 2 exercises starting on page 2-51.

Detailed solutions are provided starting on page 2-52.

Exercises

38

Chapter 2: Working with Data in a Project

2.1 Introduction to Tabular Data

2.2 Accessing Local Data

2.3 Accessing Remote Data

2.4 Importing Text Files

2.5 Editing Tables in the Data Grid (Self-Study)2.5 Editing Tables in the Data Grid (Self-Study)

39

Objectives Use the Data Grid to delete columns and rows. Use the Data Grid to modify column attributes

and sort a table. Use the Expression Builder to create columns.

40

Data GridWhen you add a table to a project, the Data Grid’s default behavior is to display the table automatically in read-only mode.

Actions available in the Data Grid in read-only mode include the following: browsing SAS tables and other tables resizing row and column widths for better viewing copying rows and columns to paste into a new or

existing SAS table hiding rows and columns from view holding rows and columns while scrolling

41

Data GridActions available in the Data Grid in update mode are limited to SAS tables and include all actions available in read-only mode, as well as the ability to do the following: edit data values change the names of columns apply labels and formats to columns delete rows and columns sort by multiple columns in ascending or descending

order create new columns and add rows

When you modify a table through the Data Grid,you change the actual data values in the table.

When you modify a table through the Data Grid,you change the actual data values in the table.

42

Data Grid: Creating a Column

43

Column Properties: General Tab

Type a name upto 32 characters

in length.

Type theexpression…

…or use theExpression

Builder.

Set thecolumn type.

44

Expression Builder: Creating a ColumnOne use of the Expression Builder is to insert a new column into a data table that is computed from other columns or values.

45

Expression Builder: Function Tab

Read a description of the function.

Selectthe type

of function. Selecta specificfunction.

46

Expression Builder: Values Tab

Select thecolumn nameto include it

in the expression.

Click on the table to view its column

names.

47

Data Grid: Results

48

ScenarioLLB’s UPDATEORDERS table must be updated. Delete the UnitsInStock column because the

information is no longer needed. Delete order #0713 because the order was cancelled. Create a new column called Revenue that is

computed as Quantity * SellPrice.

49

This demonstration illustrates how to switch from Read-only mode to Update mode in the Data Grid in order to modify a SAS table.

Working with Tablesin the Data Grid

Recommended