Differences between revisions 1 and 2
Revision 1 as of 2023-01-13 20:58:07
Size: 831
Comment:
Revision 2 as of 2023-06-14 15:44:30
Size: 887
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

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)