9-01-2006

SAS Syntax


 

/* Import the dataset */

 

libname Psyc 'C:\PSYC281';

proc import

out= Psyc.HWK1

datafile= 'C:\PSYC281\ta01_009.txt'

DBMS= TAB REPLACE;

GETNAMES= YES;

DATAROW= 2;

run;

proc print data=hwk1;

run;

 

/*Problem 1.37b:

Summary statistics and plots for GPA and Self Concept */

proc univariate data=PSYC.HWK1 plot round=.1;

histogram /normal barwidth=6 cfill=red;

var GPA ;

run;

 

/* Sort the dataset by gender */

proc sort data=PSYC.HWK1;

by gender;

run;

 

/*Problem 1.37d:

Statistics and plots of GPA by Gender */

proc univariate data=PSYC.HWK1 plot round=.1;

class gender;

histogram /kernel(c=2 k=normal color=blue fill w=3)

HOFFSET=0 midpoints = 3 to 11 by 1;

var GPA;

run;

quit;

 

 

/* Problem 1.38: 

Summary statistics for IQ, note that we have fitted a

normal curve on the histogram with mean at 100 */

proc univariate mu0=100 data=PSYC.HWK1 plot;

histogram / NORMAL(MU=100) kernel(c=1.7 k=normal color=RED w=3);

var IQ;

run;

quit;

 

 

/* Problem 1.39: 

Summary statistics for SELF CONCEPT, note that we have fitted a

normal curve on the histogram with mean at 100 */

proc univariate data=PSYC.HWK1 plot NOPRINT;

histogram CONCEPT / kernel(c=1.1 k=normal color=SALMON FILL w=4) CFILL=STEEL;

run;

quit;

 

 

 

 

SPSS Syntax

/* GET DATA is the SPSS equivalent of SAS PROC IMPORT */

GET DATA

  /type = TXT

  /file = 'F:\Psyc 281\HWK1\ta01_009.TXT'

  /delimiters = "\t"

  /arrangement = DELIMITED

  /firstcase = 2

  /variables =

   OBS F2.1

   GPA F5.2

   IQ F3.2

   Gender F3.2

   SlfCncpt F2.1.

 

EXAMINE variables=GPA SlfCncpt

  /plot boxplot stemleaf histogram

  /percentiles(5,10,25,50,75,90,95)

  /statistics descriptives.

 

EXAMINE variables=GPA by Gender

  /plot boxplot stemleaf histogram

  /percentiles(5,10,25,50,75,90,95)

  /statistics descriptives

  /nototal.

 

EXAMINE variables=IQ

  /plot boxplot stemleaf

  /percentiles(5,10,25,50,75,90,95)

  /statistics descriptives.

GRAPH

  /histogram(NORMAL)=IQ.