select if and perform analysis loop

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

select if and perform analysis loop

Jaosn
I cannopt figure out why this code doesn't work and am not sure what is
wrong. Any help would be appreciated.  I am new to writing macros in syntax.

The idea is to perform a select if loop and run analysis on each case
selected.

The code was supposed to
1. Select instructor 1
2. Create a graph
3. Select only comments with data and summarize the comments
4. Repeat until last instructor.



SORT CASES BY instructor.
AGGREGATE OUTFILE=*
 /PRESORTED
 /BREAK=instructor
 /notused=N.
WRITE OUTFILE='d:\temp\macro calls.sps'
 /"!doit instr='"instructor"'.".
EXECUTE.


*///////////////.
DEFINE !doit (instr=!TOKENS(1))
SET MPRINT=yes.
TEMPORARY.

SELECT IF instructor=!instr.

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=module MEAN(instr1) MEAN(
  instr2) MEAN(instr3) MEAN(instr4) MISSING=LISTWISE REPORTMISSING=NO
  TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX")
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: module=col(source(s), name("module"), unit.category())
 DATA: INDEX=col(source(s), name("#INDEX"), unit.category())
 DATA: SUMMARY=col(source(s), name("#SUMMARY"))
 COORD: rect(dim(1,2), transpose(), cluster(3,0))
 GUIDE: axis(dim(2), label("1= Strongly Disagree to 5= Strongly Agree"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label(""))
 GUIDE: text.title(label("Instructor Ratings"))
 SCALE: cat(dim(3), reverse())
 SCALE: linear(dim(2), min(1), max(5), origin(4))
 SCALE: cat(dim(1), include("0", "1", "2"))
 ELEMENT: interval(position(INDEX*SUMMARY*module), color.interior(INDEX),
  shape.interior(shape.square))
END GPL.

USE ALL.
COMPUTE filter_$=(comments ~= "").
VARIABLE LABEL filter_$ 'comments ~= ""'+
 ' (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

SUMMARIZE
  /TITLE='Comments'
  /TABLES=comments  by module
  /FORMAT=VALIDLIST NOTOTAL NOCASENUM
  /MISSING=VARIABLE
  /CELLS=NONE .



SET MPRINT=no.
!ENDDEFINE.
*///////////////.

=====================
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: select if and perform analysis loop

ViAnn Beadle
So exactly what gets generated and what are the errors?

BTW, this looks to me that SPLIT FILE on the instructor variable should do
it for the GGRAPH and SUMMARIZE commands.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Jaosn
Sent: Wednesday, November 28, 2007 9:35 AM
To: [hidden email]
Subject: select if and perform analysis loop

I cannopt figure out why this code doesn't work and am not sure what is
wrong. Any help would be appreciated.  I am new to writing macros in syntax.

The idea is to perform a select if loop and run analysis on each case
selected.

The code was supposed to
1. Select instructor 1
2. Create a graph
3. Select only comments with data and summarize the comments
4. Repeat until last instructor.



SORT CASES BY instructor.
AGGREGATE OUTFILE=*
 /PRESORTED
 /BREAK=instructor
 /notused=N.
WRITE OUTFILE='d:\temp\macro calls.sps'
 /"!doit instr='"instructor"'.".
EXECUTE.


*///////////////.
DEFINE !doit (instr=!TOKENS(1))
SET MPRINT=yes.
TEMPORARY.

SELECT IF instructor=!instr.

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=module MEAN(instr1) MEAN(
  instr2) MEAN(instr3) MEAN(instr4) MISSING=LISTWISE REPORTMISSING=NO
  TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX")
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
 SOURCE: s=userSource(id("graphdataset"))
 DATA: module=col(source(s), name("module"), unit.category())
 DATA: INDEX=col(source(s), name("#INDEX"), unit.category())
 DATA: SUMMARY=col(source(s), name("#SUMMARY"))
 COORD: rect(dim(1,2), transpose(), cluster(3,0))
 GUIDE: axis(dim(2), label("1= Strongly Disagree to 5= Strongly Agree"))
 GUIDE: legend(aesthetic(aesthetic.color.interior), label(""))
 GUIDE: text.title(label("Instructor Ratings"))
 SCALE: cat(dim(3), reverse())
 SCALE: linear(dim(2), min(1), max(5), origin(4))
 SCALE: cat(dim(1), include("0", "1", "2"))
 ELEMENT: interval(position(INDEX*SUMMARY*module), color.interior(INDEX),
  shape.interior(shape.square))
END GPL.

USE ALL.
COMPUTE filter_$=(comments ~= "").
VARIABLE LABEL filter_$ 'comments ~= ""'+
 ' (FILTER)'.
VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .

SUMMARIZE
  /TITLE='Comments'
  /TABLES=comments  by module
  /FORMAT=VALIDLIST NOTOTAL NOCASENUM
  /MISSING=VARIABLE
  /CELLS=NONE .



SET MPRINT=no.
!ENDDEFINE.
*///////////////.

=====================
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: select if and perform analysis loop

Art Kendall-2
In reply to this post by Jaosn
if I understand what you are trying to do, lose the macro and put the
commands it contains in line in the syntax. and
then insert
SPLIT FILE BY instructor.

after the aggregate command.
This should at least bring you closer to what you are trying to do.

Art Kendall
Social Research Consultants

Jaosn wrote:

> I cannopt figure out why this code doesn't work and am not sure what is
> wrong. Any help would be appreciated.  I am new to writing macros in syntax.
>
> The idea is to perform a select if loop and run analysis on each case
> selected.
>
> The code was supposed to
> 1. Select instructor 1
> 2. Create a graph
> 3. Select only comments with data and summarize the comments
> 4. Repeat until last instructor.
>
>
>
> SORT CASES BY instructor.
> AGGREGATE OUTFILE=*
>  /PRESORTED
>  /BREAK=instructor
>  /notused=N.
> WRITE OUTFILE='d:\temp\macro calls.sps'
>  /"!doit instr='"instructor"'.".
> EXECUTE.
>
>
> *///////////////.
> DEFINE !doit (instr=!TOKENS(1))
> SET MPRINT=yes.
> TEMPORARY.
>
> SELECT IF instructor=!instr.
>
> * Chart Builder.
> GGRAPH
>   /GRAPHDATASET NAME="graphdataset" VARIABLES=module MEAN(instr1) MEAN(
>   instr2) MEAN(instr3) MEAN(instr4) MISSING=LISTWISE REPORTMISSING=NO
>   TRANSFORM=VARSTOCASES(SUMMARY="#SUMMARY" INDEX="#INDEX")
>   /GRAPHSPEC SOURCE=INLINE.
> BEGIN GPL
>  SOURCE: s=userSource(id("graphdataset"))
>  DATA: module=col(source(s), name("module"), unit.category())
>  DATA: INDEX=col(source(s), name("#INDEX"), unit.category())
>  DATA: SUMMARY=col(source(s), name("#SUMMARY"))
>  COORD: rect(dim(1,2), transpose(), cluster(3,0))
>  GUIDE: axis(dim(2), label("1= Strongly Disagree to 5= Strongly Agree"))
>  GUIDE: legend(aesthetic(aesthetic.color.interior), label(""))
>  GUIDE: text.title(label("Instructor Ratings"))
>  SCALE: cat(dim(3), reverse())
>  SCALE: linear(dim(2), min(1), max(5), origin(4))
>  SCALE: cat(dim(1), include("0", "1", "2"))
>  ELEMENT: interval(position(INDEX*SUMMARY*module), color.interior(INDEX),
>   shape.interior(shape.square))
> END GPL.
>
> USE ALL.
> COMPUTE filter_$=(comments ~= "").
> VARIABLE LABEL filter_$ 'comments ~= ""'+
>  ' (FILTER)'.
> VALUE LABELS filter_$  0 'Not Selected' 1 'Selected'.
> FORMAT filter_$ (f1.0).
> FILTER BY filter_$.
> EXECUTE .
>
> SUMMARIZE
>   /TITLE='Comments'
>   /TABLES=comments  by module
>   /FORMAT=VALIDLIST NOTOTAL NOCASENUM
>   /MISSING=VARIABLE
>   /CELLS=NONE .
>
>
>
> SET MPRINT=no.
> !ENDDEFINE.
> *///////////////.
>
> =====================
> 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