STEP 1 : Open SPSS Editor
Once you click on Syntax a new syntax editor screen will be displayed as shown below.
STEP 2 : DATA LIST and BEGIN-END DATA commands
The DATA LIST and BEGIN - END DATA commands are used to input data through syntax editor . This is the best way when you want to keep your data and the program for reading your data together.
DATA LIST defines the names and column locations of the variables.
There are two major variants of DATA LIST, which are fixed format and free format.
1. DATA LIST FIXED : To read data files that have values at fixed positions on each line of single-line or multi-line records. The keyword FIXED is optional
2. DATA LIST LIST : Free- format data with one case on each record.
3. DATA LIST FREE : Free - format data.
BEGIN DATA and END DATA must be used together. END DATA must appear by itself on a single line, with no leading white space and exactly one space between the words END and DATA.
Example of DATA LIST FIXED : (Fixed Format)
Note : The keyword FIXED is optional
Example of DATA LIST LIST : (Free- format data with one case on each record)
Example of DATA LIST FREE : (Free- format data)
How to submit a syntax
To change format of a variable
1. Numeric values with two decimals (For example, 2545.75):
FORMATS Price (F8.2).
2. Currency values with two decimals (For example, $2,545.75) :
FORMATS Price (DOLLAR9.2).
3. Numeric values with a comma (For example, 2,545.75) :
FORMATS Price (COMMA9.2).
4. Numeric values with a trailing percent sign ( For example, 254.58%) :
FORMATS Hike (PCT9.2).
5. Text cases upto 15 characters ( For example, Deepanshu) :
FORMATS Name (A15).
6. Converting all variables to a particular format :
FORMATS ALL (F8.2).
7. International date format ( For example, 22-APR-1987) :
FORMATS date (DATE11).
8. American date format ( For example, 10/17/1987) :
FORMATS date (ADATE10).
9. Month ( For example, OCT) :
FORMATS month (MONTH3).
10. Day of the week ( For example, MO) :
FORMATS day (WKDAY2).
11. Time ( For example, 11:15) :
FORMATS time (TIME5).
12. Date and time ( For example, 29 21:15) :
FORMATS dt (DTIME1).
Go to File >> New >> Syntax
The DATA LIST and BEGIN - END DATA commands are used to input data through syntax editor . This is the best way when you want to keep your data and the program for reading your data together.
DATA LIST defines the names and column locations of the variables.
There are two major variants of DATA LIST, which are fixed format and free format.
1. DATA LIST FIXED : To read data files that have values at fixed positions on each line of single-line or multi-line records. The keyword FIXED is optional
2. DATA LIST LIST : Free- format data with one case on each record.
3. DATA LIST FREE : Free - format data.
BEGIN DATA and END DATA must be used together. END DATA must appear by itself on a single line, with no leading white space and exactly one space between the words END and DATA.
Example of DATA LIST FIXED : (Fixed Format)
DATA
LIST /date (ADATE10).
BEGIN
DATA.
4/1/2008
5/7/2012
3/21/2009
END
DATA.
|
Note : The keyword FIXED is optional
Example of DATA LIST LIST : (Free- format data with one case on each record)
DATA
LIST LIST / Name (A20) score percent.
BEGIN
DATA.
"David",27,93
"Nitin",41,85
"Jon",74,45
END
DATA.
|
Example of DATA LIST FREE : (Free- format data)
DATA
LIST FREE / Name (A20) score percent.
BEGIN DATA.
"David",27,93,"Nitin",41,85,"Jon",74,45
END DATA.
|
How to submit a syntax
Copy and Paste the syntax above into SPSS syntax editor. Select the syntax and Press Ctrl + R |
To change format of a variable
1. Numeric values with two decimals (For example, 2545.75):
FORMATS Price (F8.2).
2. Currency values with two decimals (For example, $2,545.75) :
FORMATS Price (DOLLAR9.2).
3. Numeric values with a comma (For example, 2,545.75) :
FORMATS Price (COMMA9.2).
4. Numeric values with a trailing percent sign ( For example, 254.58%) :
FORMATS Hike (PCT9.2).
5. Text cases upto 15 characters ( For example, Deepanshu) :
FORMATS Name (A15).
6. Converting all variables to a particular format :
FORMATS ALL (F8.2).
7. International date format ( For example, 22-APR-1987) :
FORMATS date (DATE11).
8. American date format ( For example, 10/17/1987) :
FORMATS date (ADATE10).
9. Month ( For example, OCT) :
FORMATS month (MONTH3).
10. Day of the week ( For example, MO) :
FORMATS day (WKDAY2).
11. Time ( For example, 11:15) :
FORMATS time (TIME5).
12. Date and time ( For example, 29 21:15) :
FORMATS dt (DTIME1).
Share Share Tweet