/* Writing Valid Syntax */ * Commands begin with a keyword, end with a period "." (on most operating systems), and usually * include a mix of key words and user-chosen variable names. *e.g COMMAND /subcommand keyword=option / subcommand variables. get file = "Y:\spss\data\cars.sav". get file = "Y:\spss\data\cars.sav" /keep=mpg weight. * See DESCRIPTIVES example in the Syntax Reference Guide. descriptives variables=mpg. descriptives variables=mpg /statistics. descriptives variables=mpg /statistics=default. get file = "Y:\spss\data\cars.sav". descriptives variables=all. descriptives variables=all /sort. /* Capitalization does not matter */ GET FILE='Y:\SPSS\Data\1991 U.S. General Social Survey.sav'. get file = "Y:\spss\data\cars.sav". /* Under Windows, commands may start in any column, and end with a period at the end of a line. */ GET FILE='Y:\SPSS\Data\1991 U.S. General Social Survey.sav'. * However, with other operating systems, commands must begin in column one, so it is a good habit to always start your commands in column one. /* Commands may be continued on more than one line. Any continuation _should_ leave column one empty. */ /* This works well: */ FREQUENCIES VARIABLES=sex. /* Under Windows, this also works, but under other operating systems it doesn't: */ FREQUENCIES VARIABLES=sex. /* Blank lines in the middle of commands never work: */ FREQUENCIES VARIABLES=sex. /* But blank lines between commands are fine. */ get file = "y:\spss\data\cars.sav". frequencies variables=year . * You may use spaces or not between tokens. compute kilos=weight/2.20462. compute kpl = mpg / (0.621371 * 3.78541) . execute. * It is possible to abbreviate most SPSS keywords, although this is not common practice. So you may occasionally see code that looks like this: . fre var=year . * Comments: three ways to specify comments. * pounds/(pounds/kilogram). compute kilos=weight/2.20462. comment "kpl" is kilometers per liter. This is calulated as (miles/gallon) / ((miles/kilometers) * (liters/gallon)). compute kpl = mpg / (0.621371 * 3.78541) . execute. * Note: Correlation is unchanged by change of scale. correlations variables= kilos kpl /*weight mpg.. graph /scatterplot = kilos with kpl. correlations variables= /*kilos kpl*/ weight mpg. graph /scatterplot = weight with mpg.