SAS Tutorial Continued

Manipulating the Data to answer the Research Questions:

Outlined below and throughout the next few pages is the SAS code needed to perform the analysis of our data set.  The format is exactly the same was will be needed in SAS including Tag Lines which will describe the steps taken and the need for the steps.

/*We are going to assume that you have imported the data set into SASUSER and named the file AOD (Alcohol and Other Drugs)*/

/*The first thing we need to do is establish a Library to which our data should be stored and the location on our C:\ drive.*/

LIBNAME AOD 'C:\PROGRAM';
/*We have now created a library which will be stored on our C: drive under Programs.  If you have not established a file called PROGRAMS on your C: the Library will not create.*/

/*It is now time to begin the data manipulation.  The first thing we want to do is determine if SAS has changed any of our variable names.*/
PROC CONTENTS DATA=SASUSER.AOD;
RUN;
/*This will provide us with an output  which will demonstrate the variable name, type (Character or Numeric), Size, old variable name (if different).*/

/*Next we will be changing some variable types from Character to Numeric to allow us to use the information in our Regression and ANOVA analysis.*/

DATA SASUSER.AOD;
      SET SASUSER.AOD;
      IF GROUP='Traditional' THEN GROUP=0;
      ELSE IF GROUP='New' THEN GROUP=1;
      IF GENDER='M' THEN GENDER=0;
      ELSE IF GENDER='F' THEN GENDER=1;
      IF ETHNICI='WHITE' THEN RACE=0;
      ELSE IF ETHNICI='BLACK' THEN RACE=1;
      ELSE IF ETHNICI='ASIAN' THEN RACE=2;
      ELSE IF ETHNICI='HISPANIC' THEN RACE=3;
      IF MARITAL='SINGLE' THEN STATUS=0;
      ELSE IF MARITAL='MARRIED' THEN STATUS=1;
      ELSE IF MARITAL='DIVORCED' THEN STATUS=2;
      IF EMOTION='UP' THEN FEEL=0;
      ELSE IF EMOTION='MIDDLE' THEN FEEL=1;
      ELSE IF EMOTION='DOWN' THEN FEEL=2;
RUN;
/*These operations will convert character variables to numeric variables, so within the same variable column, others in new variable columns.*/

Return to Previous Page                         Forward to Next Page                                                                           
     

To contact us:

Phone: 607-255-9991
Email: mls63@cornell.edu