1 using the syntax window aka learning a new language!
TRANSCRIPT
1
Using the Syntax window AKA Learning a new language!
2
Why use syntax?
• To keep a record of computations & analyses – They can get to be too many to recall (esp.. if you
are doing ‘exploratory’ analyses)– One may end of redoing analyses them OR– Do analyses differently when redoing them which
can cause different & confusing results
3
What is a syntax window?
• Allows you to type in the modifications of the variables you have
• Allows you to type/paste in the analyses you like to conduct
4
Syntax in EXCEL
Syntax in SPSS
Compute lifesat =mean(item1, item2, item3).
5
What we did so far…what’s next
• What is syntax
• Why do syntax
• How is syntax done in SPSS vs EXCEL
6
Example of Syntax in EXCEL
Example of Syntax in SPSS
Compute lifesat =mean(item1, item2, item3).
7
Features of Syntax in Excel
• In EXCEL you type/paste syntax in the function box
8
Features of a syntax window in SPSS
•In SPSS you type/paste functions in a separate window/file which takes the extension .sps (cf. .doc, .ppt)
•See next slide for example of the window
9
The syntax window in SPSS
10
Syntax in SPSS vs EXCEL
• Done in the same ‘location’ in EXCEL (i.e., in function box) above the data
• Can also be done in the same location in SPSS, But SPSS provides a “shortcut” for some types of syntax…
• Analyses syntax
• Computations syntax
11
What are Analyses & Computations
• Computations – e.g., recoding variables; or creating new variables
means of items
• Analyses – e.g., correlations, reliabilities, frequencies, means
etc. YOU ALREADY KNOW THIS!• Note means of items are different from means in the
sample…more later…
12
Generate syntax for analyses in SPSS
• Download & open the student satisfaction survey data
• Go to the correlational analyses window, pick the two variables you want to correlate
• Then click on ‘paste’ when in correlational analysis menu
• Go to the syntax window – Click under window on top right
13
• Students work on their own & do correlational analyses for any two variables in the and generate syntax
14
Screen you should be at when you successfully paste the correlational
Analyses from the Data Window into the Syntax window
15
Students continue working in syntax window…
•Select the analyses pasted in the syntax window•Click on RUN button on top right
16
What we did so far…what’s next
• What is syntax
• Why do syntax
• How is syntax done in SPSS vs EXCEL– Syntax in SPSS is different for
• Analyses vs.
• Computations
– Syntax in EXCEL is same for analyses & computations
17
Syntax for computations in SPSS vs EXCEL
• In SPSS, you need to open a separate syntax window
• In EXCEL you can directly start typing your computations in the function window
18
How to open a syntax window
19
Close look at Syntax in EXCEL
• In the example above– “STDEV” is the type of the function
•Can be substituted w/mean, sum
– “A2: A16” in parenetheses are cell values on which the function is to be performed •e.g., the values in cells A2 to A16 should
be used to compute the std dev
20
How the Syntax in SPSS differs & is similar to that in EXCEL
Compute lifesat =mean(item1, item2, item3).
• Differences from EXCEL– Comma in between items vs. colon– Period at the end of the statement
• Similarities w/Excel– Can use ‘sum’ and other operands similarly– Items enclosed in parens after the ‘function’
21
More ‘Rules’ of Syntax in SPSS
Compute lifesat =mean(item1, item2, item3).– Lifesat is now new variable you computed in your
data – Features of the variable name (e.g., lifesat)
• is 8 characters or fewer
• Cannot be the same as the name of another variable already in data set
• It cannot start with a numeric value
22
What we did so far…what’s next
• What is syntax
• Why do syntax
• How is syntax done in SPSS vs EXCEL– Syntax in SPSS is different for
• Analyses vs.
• Computations
– Syntax in EXCEL is same for analyses & computations
23
Why use syntax?
• To keep a record of computations & analyses – They can get to be too many to recall (esp.. if you are
doing ‘exploratory’ analyses)– One may end of redoing analyses them OR– Doing analyses differently when redoing them
which can cause different & confusing results– Check the accuracy of your analyses
24
Checking the accuracy of your analyses and keeping them consistent across
iterations with syntax files
• e.g., *reverse scoring negatively worded LS items.
• “*” at beginning and “.” at end enables you to use English to make notes about nature of analyses/computations in syntax files
– E.g.,*wage is related to education after controlling for SAT scores.
– E.g., *tests hypo that wage is related to education after controlling for GPA -- not supported.
25
Taking advantage of SPSS syntax
• Being accurate
• Being consistent
• Rechecking analyses
• Keeping records
• Utilizing multi-item scales
26
Computing multi-item scale scores in SPSS using Syntax Window
• What is a multi-item scale?
• Why use a scale score rather than an individual item?
27
Before computing scale scores, first reverse score differently worded items
• Recode item1 (5=1) (4=2) (2=4) (1=5).
• Additional things you can do– Can recode multiple items
• Recode item1 item5 (5=1) (4=2) (2=4) (1=5).
– Can use ‘to’ statement for multiple items • Recode item1 to item10 (5=1) (4=2) (2=4) (1=5).
– If items to be reverse scored are lined up in the data file in that order
28
After reverse scoring, then compute means of items
• Compute ls =mean(item1, item2, item3).
– How is this different from the results you get in “descriptives” analyses and you get the mean of item1?
• Students do the analyses and orally explain
29
Students Compute scale scores for Global Life Satisfaction (LS)
• Recode Negatively worded Life Satisfaction items– How can you check you did it correctly?
• Compute a life Satisfaction scores by taking the mean of all items– Can only do after reverse scoring– Why not take the sum of all items? Advantages
vs. disadvantages– What types of things can/should you take sums
of?
30
Generalizing what you learned about computations & applying it
to statistical analyses
31
Students correlate LS with specific types of satisfaction & stressors
• Compute reliabilities for each specific type of satisfaction & each type of stress
• Compute scale scores for each – Ensure you recode appropriately
• Correlate lifesat with each type of sat & each type of stress
32
• Does a stressor in relationship, work, school affect the relevant type of satisfaction which in turn affects life satisfaction?– Do Mediator regression analyses
• Which type of specific satisfaction best predicts overall life satisfaction– Do Stepwise regression
LS, specific types of satisfaction, Stress