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) 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 Objectives 3 State the definition of a SAS table. State how data is stored in a SAS table. Introduction To 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. 4 Common Data Formats SAS Enterprise Guide can read and use data from a variety of different formats. Fixed-width and delimited text files dBASE files Microsoft Excel spreadsheets ODBCcompliant data HTML tables OLE DB provider’s files SAS tables 5 Microsoft Access tables SAS Data Tables A SAS data table is a rectangular table of rows and columns. Rows (observations) Columns (variables) 6 SAS Data Tables All columns must have a name, type, and length. Names can be 1 to 32 characters long. 7 SAS Data Tables A column’s type is either character or numeric. The type plays a role in determining the length. Character values are 1 to 32,767 characters (bytes) long. 8 Numeric values are 8 bytes of floating point storage: Numeric Currency Date (days from 01JAN1960) Time (seconds from midnight) SAS Data Tables A format is used to control how values are displayed. Formats do not affect how values are stored. Format: MMDDYY Width: 10 Stored value: 15060 9 Format: DOLLAR Width: 10 Decimal Places: 0 Stored value: 76806 Formats 10 SAS Data Table Properties 11 Missing Values If 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. . . . 12 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) 13 Objectives 14 Add a local Excel spreadsheet to the project. View the properties of the data. Software File Attributes The software file contains metadata. The software file does not contain metadata. 15 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 16 Scenario Add an Excel spreadsheet to the project to provide a list of supplier names and addresses. 17 Adding a Local Excel Spreadsheet to the Project This demonstration illustrates how to add a local Excel spreadsheet to the project. 18 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) 19 Objectives 20 Identify remote data sources. Access a remote server. Add remote data to a project. Transparent Access to Remote Data Oracle sas Oracle DB2 z/OS Mainframe sas UNIX sas Local User 21 Windows Server sas Opening Data from a SAS Server The Libraries icon enables access to predefined folders containing SAS or DBMS data sources. 22 The Files icon enables access to the directories available on the server. Accessing Remote Data The Server List window also provides an organized view of all of your files and data sources. Server List 23 Accessing Remote Data After you add a data source to a project, the table automatically opens in the Data Grid. 24 Accessing Remote Data To prevent a table from opening automatically when added to a project, disable the following option by selecting Tools Options. 25 Scenario Add a remote DB2 table to the project. The table contains information on the transactions for products and stores. 26 Adding a Remote Table to a Project This demonstration illustrates how to add a remote data table to the project. 27 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) 28 Objectives 29 Use the Import Data task to import a text file into a project as a SAS table. Import Data Task The Import Data task can be used to convert a file into a customized SAS data table. 30 Import Data Task To 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). 31 Import Data Task The 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 32 Import Data Task The Import Data task stores the data as a SAS table. 33 Scenario LLB 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 34 Scenario Orders.txt 35 Orders.sas7bdat Adding Data from a Fixed-width Text File This demonstration illustrates the functionality available when you use the Import Data task to read data. 36 Exercises Complete the Chapter 2 exercises starting on page 2-51. Detailed solutions are provided starting on page 2-52. 37 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) 38 Objectives 39 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. Data Grid When 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 40 Data Grid Actions 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. 41 Data Grid: Creating a Column 42 Column Properties: General Tab Type a name up to 32 characters in length. Set the column type. Type the expression… 43 …or use the Expression Builder. Expression Builder: Creating a Column One use of the Expression Builder is to insert a new column into a data table that is computed from other columns or values. 44 Expression Builder: Function Tab Select the type of function. Select a specific function. Read a description of the function. 45 Expression Builder: Values Tab Select the column name to include it in the expression. Click on the table to view its column names. 46 Data Grid: Results 47 Scenario LLB’s UPDATEORDERS table must be updated. 48 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. Working with Tables in the Data Grid This demonstration illustrates how to switch from Read-only mode to Update mode in the Data Grid in order to modify a SAS table. 49
© Copyright 2025 Paperzz