Wednesday 1 May 2013

Creating dummy variables (from UCLA site)

* make dummies, method 1 .
COMPUTE race1=(race=1).
COMPUTE race2=(race=2).
COMPUTE race3=(race=3).
crosstabs /tables = race by race1 
          /tables = race by race2 
          /tables = race by race3.

* make dummies, method 2 .
DO REPEAT A=race1 race2 race3 /B=1 2 3.
COMPUTE A=(race=B).
END REPEAT.
crosstabs /tables = race by race1 
          /tables = race by race2 
          /tables = race by race3.
http://www.ats.ucla.edu/stat/spss/code/dummy.htm
 

Thursday 11 April 2013

Thursday 28 March 2013

to explore more: Create a pivot table using Python

#Create a pivot table
        table = spss.BasePivotTable("Group Means",
                                    "OMS table subtype")
        table.Append(spss.Dimension.Place.row,
                     spss.GetVariableLabel(groupIndex))
        table.Append(spss.Dimension.Place.column,
                     spss.GetVariableLabel(sumIndex))

        category2 = spss.CellText.String("Mean")
        for cat in sorted(Counts):
            category1 = spss.CellText.Number(cat)
            table[(category1,category2)] = \
                   spss.CellText.Number(Totals[cat]/Counts[cat])
 
Source: SPSS online help. 

Friday 22 March 2013

Creating new variables with R

# Three examples for doing the same computations

mydata$sum <- br="" mydata="" x1="" x2=""> mydata$mean <- br="" mydata="" x1="" x2="">
attach(mydata)
mydata$sum <- br="" x1="" x2=""> mydata$mean <- br="" x1="" x2=""> detach(mydata)

mydata <- br="" mydata="" transform=""> sum = x1 + x2,
mean = (x1 + x2)/2


Source for the above code.

Thursday 21 March 2013

Tuesday 19 March 2013

Copying value labels from an existing variable...



OR you could use the values from another variable which has the same labels.
APPLY DICTIONARY
  /FROM *
  /SOURCE VARIABLES = b9a
  /TARGET VARIABLES =  occupf
  /FILEINFO
  /VARINFO ALIGNMENT FORMATS LEVEL MISSING VALLABELS = REPLACE VARLABEL WIDTH .