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 .