What are the frequently used commands in SPSS?
Command in SPSS is the way to open files, edit data, generate results and save files using its syntax window. Although you can do these things using drop-down menus, syntax makes them easier. Sometimes it becomes easier to generate results using a simple command in syntax. On the other hand generating the same result using drop-down menus is very difficult. Use of syntax also saves your time. It’s just the matter of opening the syntax editor, writing the command and running it. Writing commands means writing a set of rules. Today we are going to discuss about some frequently used commands in SPSS.
How to create a new syntax for frequently used commands?
In SPSS, creating a new syntax is very easy. First of all, you have to open the SPSS data editor window clicking on the SPSS application. Select File-> New-> Syntax. SPSS will take you into its syntax editor. This is the editor where you can write your required command (set of rules) and run it to produce desired output. To run any command you have to select the command and click on the symbol of green right arrow on the Syntax Editor.
How to write frequently used commands?
In SPSS, writing commands is really very much interesting. At the beginning you can study the commands that SPSS uses to open files, edit data, generate results and save files. I am showing how to get the command to open a file. Open the SPSS data editor window clicking on the SPSS application. Select File-> Open-> Data. Select the file that you want to open browsing the Look in option in the Open Data window. Then click on Paste. SPSS will take you into its Syntax Editor and show you the used command to open the file. In this way you can study the commands for editing data, generating results and saving files.
1) Command for opening file:
Suppose your desired file is saved in the E Drive of your PC and you have named it as 07082015_2.sav. Then the command for opening the 07082015_2.sav file is:
DATASET NAME DataSet1 WINDOW=FRONT.
2) Command for saving file:
Suppose you just created an SPSS file and you want to save it in the SPSS folder in the E Drive of your PC naming as 07082015_2.sav. Then the command for saving the 07082015_2.sav file is:
3) Command for frequency distribution:
Suppose you want to generate the frequency distribution of variable1. Then the command for generating the frequency distribution of variable1 is:
4) Command for cross-tabulation:
Suppose you have two variables – variable1 and variable2. You want to generate the cross-tabulation of these 2 variables. Then the command for generating the cross-tabulation of variable1 and variable2 is:
/TABLES=variable1 BY variable2
/COUNT ROUND CELL.
5) Command for creating value labels:
Suppose you have a variable – Company and this variable contains 3 values – 1, 2 and 3. You want to generate the value labels – Company 1, Company 2 and Company 3 for a new variable CompanyID. Then the command for generating the value labels – Company 1, Company 2 and Company 3 is:
val lab CompanyID
1 ‘Company 1’
2 ‘Company 2’
3 ‘Company 3’.