2 - Getting your data into SAS w output

2 - Getting your data into SAS w output - Getting your data...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Getting your data into SAS This lecture is based on Chapter 2 of the course text, “The Little SAS Book: A Primer”. The SAS code for many of the SAS examples in this and other chapters is in the file “Little SAS Book examples.txt”. Examples in this lecture assume that the data files are in the directory C:\Documents and Settings\Michael Walker\Desktop\Stat 212 SAS To run these examples, change the INFILE statements for your directory: INFILE ' C:\Documents and Settings\Michael Walker\Desktop\Stat 212 SAS\filename.dat '; Four methods for getting your data into SAS: 1. Enter data directly into the Viewtable window in SAS (Primer, section 2.2) 2. Create SAS data set from raw data files (Primer, section 2.2-2.16) 3. Convert other software’s datasets into SAS data sets (Primer, section 2.3,2.17) 4. Read other software’s data file directly (Primer, section 2.1) Enter data directly into the Viewtable window in SAS You can enter data into the Viewtable in much the same way you enter data into Excel. We won’t spend more time on this method. See the Primer, section 2.2. Create SAS data set from raw data files. Raw data files are also called text, ASCII, sequential or flat files. Under Windows on the PC, you commonly read these files using either Notepad or Wordpad. Many programs (such as Excel) can save data in raw data format. Two methods for reading raw data files in SAS: Use the DATA step. This method works for almost any type of raw data file. Use the Import Wizard (Section 2.3) We’ll focus on these methods for most of this lecture Convert other software’s datasets into SAS data sets The IMPORT procedure and the Import Wizard can convert files from Excel, Lotus, dBase and Microsoft Access into SAS datasets, but you must have SAS/ACCESS for PC File Format software installed on your computer. See the Primer, section 2.3,2.17.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Read other software’s data file directly. SAS/ACCESS can also directly read files from Oracle, DB2, Ingres and Sybase. See the Primer, section 2.1 Reading files with the Import Wizard. Primer, Section 2.3 The Import Wizard can read delimited raw data files, including comma-separated values (CSV) files, which are produced by Excel and many other applications. If you have SAS/ ACCESS, the Import Wizard can also read some PC file types. In SAS, select File/ Import data … / Browse to the CSV file Use the WORK library as the destination In the “member” field, give the name you want SAS to use for the dataset, such as “csvexample” The Import Wizard will offer to create a file containing the import SAS commands. I suggest you create the file, so that later you can see how the data were imported. After importing, have a look at the LOG to make sure the import was successful. If so, go to the SAS Explorer window, select Libraries, then select the WORK library, which should contain your file. Double click on the data set in the Explorer window to open it in a Viewtable window.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

2 - Getting your data into SAS w output - Getting your data...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online