Differences between revisions 2 and 3
Revision 2 as of 2023-06-14 15:44:30
Size: 887
Comment:
Revision 3 as of 2023-06-14 15:44:43
Size: 893
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
SPSS macros offer the following options for looping. SPSS macros offer the following options for '''looping'''.

SPSS Macro Looping

SPSS macros offer the following options for looping.


Ranges

define !per_year(var = !tokens(1)
                /timevar = !tokens(1)
                /start = !tokens(1)
                /end = !tokens(1))
  !DO !y = !start !TO !end !BY 1
    temporary.
    select if !timevar=!y.
    frequencies /variables=!var.
    execute.
  !DOEND
!enddefine

!per_year var=population timevar=year start=2000 end=2008.


Iteration

define !each_year(var = !tokens(1)
                 /timevar = !tokens(1)
                 /years = !cmdend)
  !DO !y !IN (!years)
    temporary.
    select if !timevar=!y.
    frequencies /variables=!var.
    execute.
  !DOEND
!enddefine

!each_year var=population timevar=year years=2000 2002 2008.


CategoryRicottone

SPSS/Macro/Looping (last edited 2023-06-14 15:44:43 by DominicRicottone)