Practical Data Management and Statistical Computing (BioEp691F)

Contacts

Outline
Assignments

Resources


Outline: Lec1 Lec2 Lec3 Lec4 Lec5 Lec6 Lec7 Lec8 Lec9 Lec10
Lectures: Lec1 Lec2 Lec3 Lec4 Lec5 Lec6 Lec7 Lec8 Lec9 Lec10

Lecture 3


1. Review


2. Reading Data from a Previously Saved ASCII Data File

Usually we will read in data that has been stored in a separate ASCII file with a file name. In SAS, we specify the name of the file, and its location with in INFILE statement. Rather than including the data directly in the SAS program, there is reference to data file name and location.

Avoiding Problems when Downloading a Copy of ASCII Data from the WEB to an ASCII data file

When saving data from the WEB, formating characters that are not visible may be included in the saved data set that later can cause problems when reading the data into SAS. If data are saved in a particular manner, these formating characters will be deleted in the saved file. We illustrate two ways in which ASCII data can be saved from the WEB, with formating characters deleted.

Problems When Downloading an ASCII data file from the WEB:

When saving data from the WEB, formatting characters can cause problems. We illustrate an example of the problem here.

  • Save lec1sm2.dta on the C:\DATA directory using the following:
    • Open the data set by clicking on it in your WEB browser.
    • Click on the FILE pull-down menu in your WEB browser, and then select SAVE AS, placing the file in the C:\DATA directory with the name lec1sm2.dta.
  • Copy the program dmes99p4.sas into SAS, and run the program.
  • Examine the program log (dmes99p4.log)

Discussion: The log file indicates some errors in the data that prevent SAS from reading the last variable. Inspecting the data in NOTEPAD reveals no problem. What's wrong? One possibility is that there are hidden characters (ASCII characters that do not appear on the computer screen in programs like NETSCAPE, or NOTEPAD) that are contained in the data set, and confuse SAS. By going through the steps above, other software will delete these special characters. We can identify some of these characters by reading the saved data into the SAS program window.

  • In SAS, open the data set lec1sm2.dta in the program window. You should see some characters that are not alphanumeric.


3. Reading Data in Column Input.


4. Example: Reading an External ASCII File using Column Input,Getting Contents of Dataset, and Saving the data as a Permanent Sas Data set


Readings:



Produced and maintained by the Dept of BioEpi at UMASS
Send comments or questions about this web site to Ed Stanek
Email:
stanek@schoolph.umass.edu
\be691f\web\webready\lec3.html
Lst Update: 9/27/99