SPSS macro help needed

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

SPSS macro help needed

jaycamh
Hi I need put this in a loop (possibly in a MACRO) to calculate the percentiles so i can run it FROM year 1984 to year 2012 (29 times) BY 2 sexes (M and F) by 3 age groups (15-34 y, 35-64 y, 65+ y)=29x2x3=174 times. How can i achieve this.. please guide me with a macro command. FREQUENCIES VARIABLES=DRINKSPERDAY /NTILES=5 /PERCENTILES=20.0 40.0 60.0 80.0 100.0 /STATISTICS=MINIMUM MAXIMUM MEAN /ORDER=ANALYSIS.

Sent from the SPSSX Discussion mailing list archive at Nabble.com.
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro help needed

David Marso-2
Please look at SPLIT FILE command.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro help needed

Mario Giesel-2
In reply to this post by jaycamh
Hi,

try this:

* Assuming that sex and age are numerical variables with ranges 1-2 and 1-3.
* Otherwise please (auto)recode.

DEFINE !macrohelp(year = !TOKENS(2) / sex = !TOKENS(2) / age = !TOKENS(2))
!LET !number = !NULL
!DO !y = !HEAD(!year) !TO !Tail(!year)
!DO !s = !HEAD(!sex) !TO !Tail(!sex)
!DO !a = !HEAD(!age) !TO !Tail(!age)
                    !LET !number = !CONCAT(!number,1)
         ECHO !QUOTE(!CONCAT( "Table ", !LENGTH(!number), ": Year = ",!y," | Sex = ", !s, " | Age = ", !a)).
                    TEMPORARY.
                    SELECT IF (year = !y & sex = !s & age = !a).
                    FREQUENCIES VARIABLES=DRINKSPERDAY
                     /NTILES=5
                     /PERCENTILES=20.0 40.0 60.0 80.0 100.0
                     /STATISTICS=MINIMUM MAXIMUM MEAN
                     /ORDER=ANALYSIS.
!DOEND
!DOEND
!DOEND
!ENDDEFINE.

!macrohelp year = 1984 2012 sex = 1 2 age = 1 3. 



Mario Giesel
Munich, Germany


Am Dienstag, 6. August 2019, 08:35:11 MESZ hat jaycamh <[hidden email]> Folgendes geschrieben:


Hi I need put this in a loop (possibly in a MACRO) to calculate the percentiles so i can run it FROM year 1984 to year 2012 (29 times) BY 2 sexes (M and F) by 3 age groups (15-34 y, 35-64 y, 65+ y)=29x2x3=174 times. How can i achieve this.. please guide me with a macro command. FREQUENCIES VARIABLES=DRINKSPERDAY /NTILES=5 /PERCENTILES=20.0 40.0 60.0 80.0 100.0 /STATISTICS=MINIMUM MAXIMUM MEAN /ORDER=ANALYSIS.

Sent from the SPSSX Discussion mailing list archive at Nabble.com.
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro help needed

Art Kendall
In reply to this post by jaycamh
RANK VARIABLES= varlist [({A**})] [BY varlist]
                          {D  }
 
  [/TIES={MEAN**  }]
         {LOW     }
         {HIGH    }
         {CONDENSE}
 
  [/FRACTION={BLOM**}]
             {TUKEY }
             {VW    }
             {RANKIT}
 
  [/PRINT={YES**}]
          {NO   }
 
  [/MISSING={EXCLUDE**}]
            {INCLUDE  }

The following function subcommands can each be specified once:

  [/RANK**] [/NTILES(k)] [/NORMAL] [/PERCENT]

  [/RFRACTION] [/PROPORTION] [/N] [/SAVAGE]

The following keyword can be used with any function subcommand:

  [INTO varname]



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro help needed

David Marso-2
In reply to this post by jaycamh
I believe SPLIT FILE is the appropriate solution here for several reasons.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD