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 .

Thursday, 13 December 2012

Missing Values

You may have used the command MISSING VALUES in a file to declare a certain value(s) 
as missing, for example:

MISSING VALUES V1 (8,9)
 
Here the values 8,9 will be considered missing in the data and will not be included 
in computations. 
 
 But, sometimes you want those values back. One way would be to close the file and 
reload but that is cumbersome. The short way to do that is:
 
MISSING VALUES V1 ().

The above command will remove any previously declared values from missing category to the data category.

Thursday, 16 August 2012

Data Cleaning (draft entry)

My next post will be about Data Cleaning. I am not the expert on this but I know few things. One simple way  to do this is to compare data entered by 2 different people. The command in SPSS is called

UPDATE FILE

Here is an example from UCLA site:

update file = "D:\person1.sav"
/in = flag1
/file = "D:\person2.sav"
/by all.
exe.
 
More valuable information in this pdf. 
http://www.ats.ucla.edu/stat/sas/library/nesug99/ss123.pdf
 

Need to update this blog!!