Loop (or Macro?) Question

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

Loop (or Macro?) Question

Sakari Lemola
Hello,

I would like to run a Graph-Syntax for every case in a datafile seperately
(ID = 1 to ID = 10000). Is there an easy way (with LOOP or Macro?) to change
the value of the ID variable automatically in the following syntax in order
not to manually changing the ID value and running the syntax 10000 times?

COMPUTE filter_$=(ID = 1).
FILTER BY filter_$.

GRAPH
  /BAR(SIMPLE)=MEAN(var1) MEAN(var2) .

FILTER OFF.
USE ALL.

Thanks very much

Sakari Lemola

=====================
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: Loop (or Macro?) Question

Albert-Jan Roskam
Hi,

Are you sure you REALLY want to create 10 000 graphs? It\s possible with a loop, but this is easier:
compute filter = id le 10000.
filter by filter.
sort cases by id.
split file by id.

GRAPH  /BAR(SIMPLE)=MEAN(var1) MEAN(var2) .
filter off.
split file off.

Cheers!!
Albert-Jan



----- Original Message ----
From: Sakari Lemola <[hidden email]>
To: [hidden email]
Sent: Thursday, January 15, 2009 3:43:52 PM
Subject: Loop (or Macro?) Question

Hello,

I would like to run a Graph-Syntax for every case in a datafile seperately
(ID = 1 to ID = 10000). Is there an easy way (with LOOP or Macro?) to change
the value of the ID variable automatically in the following syntax in order
not to manually changing the ID value and running the syntax 10000 times?

COMPUTE filter_$=(ID = 1).
FILTER BY filter_$.

GRAPH
  /BAR(SIMPLE)=MEAN(var1) MEAN(var2) .

FILTER OFF.
USE ALL.

Thanks very much

Sakari Lemola

=====================
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: Loop (or Macro?) Question

Sakari Lemola
Dear Albert-Jan

Thanks a lot, this is elegant and seems to work!
We need the graphs for a personalized feedback for the participants of a
study. Every one will get a print out of his response profile.

The following macro solution works as well:

COMPUTE id=$CASENUM.

///////.

DEFINE macdef (arg1 = !TOKENS(1)
              /arg2 = !TOKENS(1))
!DO !i = !arg1 !TO !arg2.

     COMPUTE filter_$=(id = !i).
     FILTER BY filter_$.

     GRAPH
       /BAR(SIMPLE)=
       MEAN(var1) MEAN(var2) MEAN(var3) MEAN(var4)
       MEAN(var5).

     FILTER OFF.
     USE ALL.

!DOEND
!ENDDEFINE.

///////.

macdef arg1 = 1 arg2 = 10000.


Sincerely

Sakari Lemola


Am 15.1.2009 21:05 Uhr schrieb "Albert-jan Roskam" unter <[hidden email]>:

> Hi,
>
> Are you sure you REALLY want to create 10 000 graphs? It\s possible with a
> loop, but this is easier:
> compute filter = id le 10000.
> filter by filter.
> sort cases by id.
> split file by id.
>
> GRAPH  /BAR(SIMPLE)=MEAN(var1) MEAN(var2) .
> filter off.
> split file off.
>
> Cheers!!
> Albert-Jan
>
>
>
> ----- Original Message ----
> From: Sakari Lemola <[hidden email]>
> To: [hidden email]
> Sent: Thursday, January 15, 2009 3:43:52 PM
> Subject: Loop (or Macro?) Question
>
> Hello,
>
> I would like to run a Graph-Syntax for every case in a datafile seperately
> (ID = 1 to ID = 10000). Is there an easy way (with LOOP or Macro?) to change
> the value of the ID variable automatically in the following syntax in order
> not to manually changing the ID value and running the syntax 10000 times?
>
> COMPUTE filter_$=(ID = 1).
> FILTER BY filter_$.
>
> GRAPH
>   /BAR(SIMPLE)=MEAN(var1) MEAN(var2) .
>
> FILTER OFF.
> USE ALL.
>
> Thanks very much
>
> Sakari Lemola
>
> =====================
> 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

=====================
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