Accessing Data and Creating Data Structures.doc

Accessing Data and Creating Data Structures.doc - Topic...

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

Topic: Accessing Data and Creating Data Structures 1. Reading raw data files using INFILE and INPUT statement 2. Writing _NULL_ Data Set 3. Assigning and change variable attributes 4. Import database table or data file into SAS dataset 5. Labeling variables 6. Reading existing SAS dataset 7. Restricting observations while reading data 8. Creating temporary and permanent SAS data sets 9. Exporting data to different files 10. Displaying contents of dataset 11. Restricting observations and variables in a SAS data set processed 1
Image of page 1

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

1. Reading raw data files using INFILE and INPUT statement ] 1.1 Introduction 1.1.1 Common Step Boundary Keywords: DATA PROC CARDS DATALINES QUIT RUN 1.1.2 Data Step Flow data sales; infile rawin; input name $1-10 division $12 years 15-16 sales 19-25; run; proc print data=sales; run; Note: The use of RUN after each step is highly recommended A. The Compilation Phase When you submit a DATA step for execution, SAS checks the syntax of the SAS statements and compiles them, that is, automatically translates the statements into machine code. In this phase, SAS identifies the type and length of each new variable, and determines whether a type conversion is necessary for each subsequent reference to a variable. During the compile phase, SAS creates the following three items: input buffer is a logical area in memory into which SAS reads each record of raw data when SAS executes an INPUT statement. Note that this buffer is created only when the DATA step reads raw data. (When the DATA step reads a SAS data set, SAS reads the data directly into the program data vector.) program data vector ( PDV ) is a logical area in memory where SAS builds a data set, one observation at a time. When a program executes, SAS reads data values from the input buffer or creates them by executing SAS language statements. The data values are assigned to the appropriate variables in the program data vector. From here, SAS writes the values to a SAS data set as a single observation. Along with data set variables and computed variables, the PDV contains two automatic variables, _N_ and _ERROR_. The _N_ variable counts the number of times the DATA step begins to iterate. The _ERROR_ variable signals the occurrence of an error caused by the data during execution. The value of _ERROR_ is either 0 (indicating no errors exist), or 1 (indicating that one or more errors have occurred). SAS does not write these variables to the output data set. descriptor information is information that SAS creates and maintains about each SAS data set, including data set attributes and variable attributes. It contains, for example, the name of the data set and its member type, the date and time that the data set was created, and the number, names and data types (character or numeric) of the variables.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '17
  • Comma-separated values, Delimiter-separated values

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern