SPSS macro training

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

SPSS macro training

albert_sun
is there any SPSS syntax level training courses provided in Australia? Serached IBT's website, but not found.

Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro training

John F Hall

Check out self-teaching syntax-based course on my site:

Survey Analysis Workshop (SPSS)

http://surveyresearch.weebly.com/1-survey-analysis-workshop-spss.html also SPSS textbooks http://surveyresearch.weebly.com/spss-textbooks.html

 

I don’t have anything on macros, but you might find something on: Introductions and tutorials for SPSS

http://surveyresearch.weebly.com/on-line-spss-intros-and-tutorials.html

 

I’ve copied this to a couple of colleagues in Australia who may be able to point you in the right direction

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

SPSS start page:  www.surveyresearch.weebly.com/1-survey-analysis-workshop

 

 

 

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of albert_sun
Sent: 23 June 2015 04:01
To: [hidden email]
Subject: SPSS macro training

 

is there any SPSS syntax level training courses provided in Australia?

Serached IBT's website, but not found.

 

 

 

 

 

--

View this message in context: http://spssx-discussion.1045642.n5.nabble.com/SPSS-macro-training-tp5729894.html

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 training

Bruce Weaver
Administrator
In reply to this post by albert_sun
I don't know about courses, but here are a couple of resources for self-study.

1. The book Next Steps with SPSS (http://www.sagepub.com/textbooks/Book9892) has a chapter on the macro facility.

2. The 2nd Edition of Raynald Levesque's book (http://www.spsstools.net/spss_programming.htm) has a chapter on macros.  (Later editions seem to change the focus to migrating macros to Python.)  

HTH.


albert_sun wrote
is there any SPSS syntax level training courses provided in Australia? Serached IBT's website, but not found.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro training

Anthony Babinec
The Syntax II course has a lesson on macros.

Tony Babinec
[hidden email]

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

David Marso
Administrator
In reply to this post by albert_sun
These should keep you out of trouble for about 3-6 months, depending upon how much sleep you need per day.
http://spssx-discussion.1045642.n5.nabble.com/template/NamlServlet.jtp?macro=search_page&node=1068821&query=ENDDEFINE&days=0
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro training

Richard Ristow
In reply to this post by albert_sun
At 10:00 PM 6/22/2015, albert_sun wrote:

>is there any SPSS syntax level training courses provided in Australia?

You asked about macro training, and several sources have been posted.

If you're going to be writing macros, here are a couple of things
that will help:

.  Don't try to write a macro to do something, until you have plain
SPSS code that does the same thing.  The plain SPSS code will work
for only one set of parameter values, those you enter in the
code;  but it will be much easier to debug.  It's much easier to
write a macro when you know the SPSS code it generates, already works.

.  As David Marso said, use MPRINT.  If MPRINT is on, the SPSS code
generated by the macro (but not the macro logic) is printed.   A
standard way to do this is,

PRESERVE.
SET MPRINT ON.
<call the macro>
RESTORE.

.  It can be useful to use the ECHO statement within a macro, for
example to print the value of some macro variable. For example,

ECHO !QUOTE(!CONCAT('Join=',!Join)).

displays the current value of macro variable !Join.

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

David Marso
Administrator
I invariably use the following technique in production code .
That keeps it all within the macro and one can optionally enable debugging.
In more elaborate code I assign different levels of debug info.
Say if debug =1 I print minimal info (trace back info).
If debug =2 more info...
This is useful when you have macros calling other macros (particularly in the matrix environment).
I might want at some extreme to have only the macro names printed, at the other extreme I might print ALL intermediate results.  The debug flag for MATRIX can be set to some global value within a main control macro so it need not be passed as a parameter to all lower level macros.
--
DEFINE !my_macro
   ( var !TOKENS(1) /debug !TOKENS(1) !DEFAULT (N)  )
PRESERVE.
!IF ( !Debug !NE N) !THEN
SET MPRINT ON.
ECHO !QUOTE(!CONCAT('var=',!var)).
!ELSE
SET MPRINT OFF PRINTBACK OFF.
!IFEND
FREQUENCIES !var .
RESTORE.
!ENDDEFINE.

DATA LIST FREE / a .
BEGIN DATA
1 2 3 2 4 5 3
END DATA.

!my_macro var=a.

!my_macro var=a debug=Y.


Richard Ristow wrote
At 10:00 PM 6/22/2015, albert_sun wrote:

>is there any SPSS syntax level training courses provided in Australia?

You asked about macro training, and several sources have been posted.

If you're going to be writing macros, here are a couple of things
that will help:

.  Don't try to write a macro to do something, until you have plain
SPSS code that does the same thing.  The plain SPSS code will work
for only one set of parameter values, those you enter in the
code;  but it will be much easier to debug.  It's much easier to
write a macro when you know the SPSS code it generates, already works.

.  As David Marso said, use MPRINT.  If MPRINT is on, the SPSS code
generated by the macro (but not the macro logic) is printed.   A
standard way to do this is,

PRESERVE.
SET MPRINT ON.
<call the macro>
RESTORE.

.  It can be useful to use the ECHO statement within a macro, for
example to print the value of some macro variable. For example,

ECHO !QUOTE(!CONCAT('Join=',!Join)).

displays the current value of macro variable !Join.

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: SPSS macro training

David Marso
Administrator
In action.

DEFINE !SSCPCalc (mat !TOKENS(1) / out !TOKENS (1) )
DO IF DEBUG GT 0.
PRINT /TITLE !QUOTE(!SSCPCalc).
END IF.
COMPUTE !out=SSCP(!mat).
DO IF debug GT 1.
PRINT !out / TITLE 'SSCP'.
END IF.
!ENDDEFINE.


DEFINE !main (debug !TOKENS(1) !DEFAULT(0) )
MATRIX.
COMPUTE DEBUG=!debug .
COMPUTE a={1,2,3; 4,3,2 ; 1,5,4}.
!SSCPCalc mat=a out=q .
COMPUTE qinv=INV(q).
PRINT qinv / TITLE 'Inverse of SSCP'.
END MATRIX.
!ENDDEFINE.

!Main .

!Main debug=1.

!Main debug=2.


David Marso wrote
I invariably use the following technique in production code .
That keeps it all within the macro and one can optionally enable debugging.
In more elaborate code I assign different levels of debug info.
Say if debug =1 I print minimal info (trace back info).
If debug =2 more info...
This is useful when you have macros calling other macros (particularly in the matrix environment).
I might want at some extreme to have only the macro names printed, at the other extreme I might print ALL intermediate results.  The debug flag for MATRIX can be set to some global value within a main control macro so it need not be passed as a parameter to all lower level macros.
--
DEFINE !my_macro
   ( var !TOKENS(1) /debug !TOKENS(1) !DEFAULT (N)  )
PRESERVE.
!IF ( !Debug !NE N) !THEN
SET MPRINT ON.
ECHO !QUOTE(!CONCAT('var=',!var)).
!ELSE
SET MPRINT OFF PRINTBACK OFF.
!IFEND
FREQUENCIES !var .
RESTORE.
!ENDDEFINE.

DATA LIST FREE / a .
BEGIN DATA
1 2 3 2 4 5 3
END DATA.

!my_macro var=a.

!my_macro var=a debug=Y.


Richard Ristow wrote
At 10:00 PM 6/22/2015, albert_sun wrote:

>is there any SPSS syntax level training courses provided in Australia?

You asked about macro training, and several sources have been posted.

If you're going to be writing macros, here are a couple of things
that will help:

.  Don't try to write a macro to do something, until you have plain
SPSS code that does the same thing.  The plain SPSS code will work
for only one set of parameter values, those you enter in the
code;  but it will be much easier to debug.  It's much easier to
write a macro when you know the SPSS code it generates, already works.

.  As David Marso said, use MPRINT.  If MPRINT is on, the SPSS code
generated by the macro (but not the macro logic) is printed.   A
standard way to do this is,

PRESERVE.
SET MPRINT ON.
<call the macro>
RESTORE.

.  It can be useful to use the ECHO statement within a macro, for
example to print the value of some macro variable. For example,

ECHO !QUOTE(!CONCAT('Join=',!Join)).

displays the current value of macro variable !Join.

=====================
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
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"