Command syntax reference
Every StatLab dialog can write its command into the Syntax editor with Paste; you can also type commands, save them as a .sps file and run them again on new data. The commands follow the style taught in most statistics courses.
How do I use the Syntax editor?
- Press Paste in any dialog, or type commands in the Syntax editor tab.
- Each command ends with a full stop at the end of a line; it may continue over several lines. Lines starting with
*and text between/*and*/are comments. - Run all (Ctrl+R) or select lines and Run selection (Ctrl+Shift+R). Problems are listed with their line numbers.
- Variable lists accept
first TO lastin data-file order, e.g.q1 TO q5. - Insert syntax log copies everything you did with the menus, so a whole analysis can be saved and repeated.
Which commands are available?
| Task | Command |
|---|---|
| Frequencies | FREQUENCIES VARIABLES=gender group /STATISTICS=ALL /BARCHART. |
| Descriptives | DESCRIPTIVES VARIABLES=age score /STATISTICS=MEAN STDDEV MIN MAX VARIANCE SKEWNESS KURTOSIS. |
| Explore | EXAMINE VARIABLES=score BY group /PLOT=BOXPLOT HISTOGRAM. |
| Crosstabs | CROSSTABS /TABLES=smoker BY gender /STATISTICS=CHISQ PHI CC /CELLS=COUNT EXPECTED ROW. |
| One-sample t test | T-TEST /TESTVAL=40 /VARIABLES=age. |
| Independent-samples t test | T-TEST GROUPS=gender(1 2) /VARIABLES=score. |
| Paired-samples t test | T-TEST PAIRS=pre WITH post (PAIRED). |
| One-way ANOVA | ONEWAY score BY group /STATISTICS=DESCRIPTIVES HOMOGENEITY WELCH /POSTHOC=TUKEY ALPHA(0.05). |
| Pearson correlation (+ scatterplot) | CORRELATIONS /VARIABLES=age score /SCATTER. |
| Spearman correlation | NONPAR CORR /VARIABLES=q1 q2 /PRINT=SPEARMAN. |
| Linear regression | REGRESSION /DEPENDENT score /METHOD=ENTER age pre q1 /RESIDUALS HISTOGRAM(ZRESID). |
| Cronbach's alpha | RELIABILITY /VARIABLES=q1 q2 q3 q4 q5 /MODEL=ALPHA. |
| Mann-Whitney U | NPAR TESTS /M-W=q1 BY gender(1 2). |
| Wilcoxon signed-rank | NPAR TESTS /WILCOXON=pre WITH post (PAIRED). |
| Kruskal-Wallis H | NPAR TESTS /K-W=score BY group. |
| Histogram | GRAPH /HISTOGRAM(NORMAL)=score. |
| Bar chart of means | GRAPH /BAR(SIMPLE)=MEAN(score) BY group. |
| Scatterplot | GRAPH /SCATTERPLOT(BIVAR)=pre WITH post /FIT. |
| Boxplot | EXAMINE VARIABLES=score BY group /PLOT=BOXPLOT /STATISTICS=NONE. |
| Compute | COMPUTE sat = MEAN(q1, q2, q3, q4, q5). |
| Conditional compute | IF (group = 3) bonus = score + 5. |
| Recode into a new variable | RECODE age (LO thru 29 = 1) (30 thru 49 = 2) (50 thru HI = 3) INTO agegrp. |
| Filter cases (keep the rest) | FILTER IF (gender = 2). |
| Delete unselected cases | SELECT IF (age >= 18). |
| Remove the filter | FILTER OFF. |
| Sort | SORT CASES BY age(D). |
| Value labels | VALUE LABELS gender 1 'Male' 2 'Female'. |
| Missing values | MISSING VALUES income (99999). |
StatLab additions: FILTER IF (condition). and FILTER OFF. (keep but ignore cases), CORRELATIONS … /SCATTER, and PROC name /option=value … for add-on procedures. Commands that StatLab does not know are reported with their line number and skipped.