9-15-2006

SAS Syntax


 

 

libname psyc 'F:\Psyc 281\HWK1';

 

/*Proc Corr is the sas procedure that produces correlation and covariance output*/

/*to correlate a set of variables list them on the var line*/

 

proc corr cov data=psyc.hwk1;

var iq concept;

run;

 

/*Proc gplot is the standard graphics procedure for producing high quality 2d graphics*/

/*This code gives you a scatter plot*/

 

proc gplot data=PSYC.HWK1;

plot iq*concept;

run;

 

/*Proc KDE is an advanced kernel density estimation procedure -- the bivar statement asks for information about

  bivariate relationships*/

 

proc kde data=psyc.hwk1;

bivar iq concept/ out=density_GP;/*here I output a data set called density_gp containing the results of proc kde*/

run;

 

/*In this data step I rename the kde output to make it more interpretable*/

/*I name the new data set (defined on the DATA line) the same as the old one (defined on the SET line)*/

 

data density_GP;

set density_GP;

iq=value1;

concept=value2;

jointDensity=density;

run;

 

/*Proc G3d is the SAS procedure that returns the 3d surface plots*/

/*Here I am plotting the joint distribution of x1 and x2*/

 

proc g3d data=density_GP;

      plot iq*concept=jointDensity / ctop=black cbottom=salmon;

        /*Color specifications -- top of surface is black, bottom is salmon*/

   run;

 

/*Proc GLM produces regression and ANOVA results -- here we are predicting self-concept from gender and iq*/

 

proc glm data=PSYC.HWK1;

model concept=gender iq;

run;

 

/*This syntax deletes previously generated graphics -- must close graphics window before invoking*/

PROC CATALOG

CAT=WORK.GSEG KILL;

RUN;

 

 

SPSS Syntax

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

GET DATA

  /type = TXT

  /file = 'G:\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

   concept F2.1.

 

/* Make scatterplot */

GRAPH

  /scatterplot(bivar)=iq with concept.

 

/* Generate the correlation coefficient */

CORRELATIONS

  /variables =iq concept.

 

/* Estimate regression parameters */

REGRESSION

  /dependent concept

  /method=enter gender iq.