**Recode and Compute Statements for Rosenberg Self-esteem** RECODE r3 r5 r8 r9 r10 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) INTO rr3 rr5 rr8 rr9 rr10. EXECUTE . COMPUTE setot = MEAN (r1, r2, r4, r6, r7, rr3, rr5, rr8, rr9, rr10) . EXECUTE . **Median Split for Rosenberg Self-esteem** if (setot gt 4.9) segroup = 2. if (setot le 4.9) segroup = 1. **List Variables Command** LIST VARIABLES = person# phone# name gender segroup setot /CASES = FROM 417 to 831 BY 1. *******Example Using Split File Command sort cases by gender. split file by gender. execute. DESCRIPTIVES VARIABLES=educ /STATISTICS=MEAN STDDEV MIN MAX . split file off. execute. ********Example Using Compute Command with Arithmetic Operators (averaging across columns) compute meanhlth=(hlth1 + hlth2 + hlth3 + hlth4 + hlth5 + hlth6 + hlth7 + hlth8 + hlth9)/9. execute. compute hlthtot = hlth1 + hlth2 + hlth3 + hlth4 + hlth5 + hlth6 + hlth7 + hlth8 + hlth9. execute. ********Example Using Compute Command with Statistical Functions (averaging across columns) compute meanhlt2=mean(hlth1, hlth2, hlth3, hlth4, hlth5, hlth6, hlth7, hlth8, hlth9). execute. compute hlthtot2=sum(hlth1, hlth2, hlth3, hlth4, hlth5, hlth6, hlth7, hlth8, hlth9). execute. ******Example Using the Recode Command Recoding into Same Variable and Different Variable RECODE work3 (1=2) . EXECUTE . RECODE work3 (1=2) INTO work3b . EXECUTE . ************Example Using the Aggregate Procedure (aggregating across rows) AGGREGATE /OUTFILE=* /BREAK=gender /age_1=MEAN(age) /N_BREAK=N. ***********Example Using Select-If Statement with the Descriptives Procedure by Creating a Filter Variable USE ALL. COMPUTE filter_$=(age < 50). VARIABLE LABEL filter_$ 'age < 50 (FILTER)'. VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'. FORMAT filter_$ (f1.0). FILTER BY filter_$. EXECUTE . DESCRIPTIVES VARIABLES=age /STATISTICS=MEAN STDDEV MIN MAX . ***********Example Using Select-If Statement with the Descriptives Procedure with the TEMPORARY Command temporary. select if (age<50). DESCRIPTIVES VARIABLES=age /STATISTICS=MEAN STDDEV MIN MAX . ***********Example Using Select-if Statement with Permanent Selection of Cases FILTER OFF. USE ALL. SELECT IF(age < 50). EXECUTE . ******Example Using the Do If-Else If-End If Structure do if (occcat80=7 or occcat80=5 or occcat80=6). compute subsidy=0. else if (occcat80=1). compute subsidy=salary*.1. else if (occcat80=2). compute subsidy=salary*.12. else if (occcat80=3). compute subsidy=salary*.08. else if (occcat80=4). compute subsidy=salary*.14. end if. execute. *******Example Using the Do Repeat-End Repeat Structure do repeat X=hlth1 to work9. recode X (1=2) (2=1). end repeat. *********Example Concatenating Two SPSS System Files ADD FILES /FILE=* /FILE='A:\Census B.sav'. EXECUTE. **********Example Merging Two SPSS System Files Via Parallel Matching MATCH FILES /FILE=* /FILE='A:\Sorted Pcvote8x.sav' /RENAME (age educ = d0 d1) /BY id /DROP= d0 d1. EXECUTE.