8-25-2006

Reading in Data in SAS and SPSS
Click here for the dataset

(To download file: right-click and choose "save target as". )

SAS Syntax


/*Reading in data for the first lab session

         -- note, enclosing text within this combination of slash and asterisks

            comments out statements

(This is useful for keeping notes on what you are doing and what you have done) */

 

      DATA COCAINE_RAT;

            INFILE "L:\Psyc 830\ratdata.txt";

                  LENGTH CONDITION $21.;      

            INPUT RAT LITTER CELL  CONDITION $ MATERNAL_AGGRESSION;

      RUN;

 

/*Proc contents tells you what variables are in the data set*/

 

      PROC contents DATA=COCAINE_RAT;

      RUN;

 

/* the print procedure shows you the data*/

 

      PROC PRINT DATA=COCAINE_RAT;

      RUN;

 

 

/* WE CAN COMPUTE THE CONDITION SPECIFIC MEANS OF MATERNAL AGGRESSION */

PROC means DATA=COCAINE_RAT; class condition;

            var MATERNAL_AGGRESSION;

      output out=coke_means mean=;

            RUN;

 

/* WE CAN PLOT THE MEANS OF MATERNAL AGGRESSION BY CONDITION */

      proc gplot data=coke_means;

            goptions;

          symbol1 value=dot color=steel interpol=join;

      plot MATERNAL_AGGRESSION*condition;

      run;

 

SPSS Syntax

/*Reading in the data*/

GET DATA

  /type = TXT

  /file = 'L:\Psyc 830\ratdata.txt'

  /delimiters = " "

  /arrangement = DELIMITED

  /firstcase = 1

  /variables =

  RAT A2

   LITTER F5.2

   CELL F5.2

   CONDITION  A21

   MATERNAL_AGGRESSION F5.2.

SAVE OUTFILE='L:\Psyc 830\ratdata.sav'.

 

/* We can print the dataset to see if it is correct. */

list.

 

/* We can compute the condition specific means of  maternal aggression. */

MEANS

TABLES=MATERNAL_AGGRESSION BY CONDITION

/CELLS MEAN STDDEV COUNT.

 

GET FILE='L:\Psyc 830\ratdata.sav'.

 

/* We can plot the means of  maternal aggression across conditions. */

IGRAPH

 /X1 = VAR(CONDITION) type=categorical

 /Y = VAR(MATERNAL_AGGRESSION) type=scale

 /LINE(MEAN) STYLE = DOTLINE INTERPOLATE = STRAIGHT.