Pairs of Correlations Macro

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

Pairs of Correlations Macro

Beckstead, Jason

Hello List Members,

I am attempting to write a macro to run several correlations. Specifically, I have two lists of variables, list1 and list2, and I want to get the correlations between variables that occupy the same position in the two lists.

For example, list1 is the variables X, Y, & Z, and list2 is the variables A, B, & C, and I only want to get these correlations (X,A), (Y,B), and, (Z,C).

I need this to work for a large number of variables (e.g., 20 in each list) when the variables are not consecutive in the file and are not subscripted.

I have tried specifying a macro with three arguments: one for the number of variables pairs, one referring to the first list, and one for the second list, but this does not work because I can't figure out how to use a loop to access the appropriate positions within each list.

 

Any suggestions?

 

Thanks in advance,

Jason

 

_____________________________________________________________

 Jason W. Beckstead, Ph.D.       

  Professor/Quantitative Methodologist

  University of South Florida College of Public Health

  13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA

  Statistical Editor, International Journal of Nursing Studies

  phone: +1.813.974.7667  fax: +1.813.974.4719          

  personal website:  http://personal.health.usf.edu/jbeckste/

  International Journal of Nursing Studies  http://www.elsevier.com/ijns

 

===================== 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: Pairs of Correlations Macro

spss.giesel@yahoo.de
Hi, Jason,

I did not test this (no SPSS at home) but see if it works:


DEFINE !cor(list1 = !CHAREND("/") /list2 = !CMDEND)
!LET !n1 = !NULL /*counter for list 1*/
!DO !var1 !IN (!list1)
!LET !n1 = !CONCAT(!n1,1)
!LET !n2 = !NULL /*counter for list 2*/
!DO !var2 !IN (!list2)
!LET !n2 = !CONCAT(!n2,1)
!IF !LENGTH(!n1) !EQ !LENGTH(!n2) !THEN
CORRELATIONS
/VARIABLES = !var1 !var2
/PRINT=TWOTAIL NOSIG
/MISSING=PAIRWISE.
!IFEND
!DOEND
!DOEND
!ENDDEFINE.

!cor list1 = a b c / list2 = d e f.


Mario Giesel
Munich, Germany

Am Mittwoch, 4. September 2019, 20:05:37 MESZ hat Beckstead, Jason <[hidden email]> Folgendes geschrieben:


Hello List Members,

I am attempting to write a macro to run several correlations. Specifically, I have two lists of variables, list1 and list2, and I want to get the correlations between variables that occupy the same position in the two lists.

For example, list1 is the variables X, Y, & Z, and list2 is the variables A, B, & C, and I only want to get these correlations (X,A), (Y,B), and, (Z,C).

I need this to work for a large number of variables (e.g., 20 in each list) when the variables are not consecutive in the file and are not subscripted.

I have tried specifying a macro with three arguments: one for the number of variables pairs, one referring to the first list, and one for the second list, but this does not work because I can't figure out how to use a loop to access the appropriate positions within each list.

 

Any suggestions?

 

Thanks in advance,

Jason

 

_____________________________________________________________

 Jason W. Beckstead, Ph.D.       

  Professor/Quantitative Methodologist

  University of South Florida College of Public Health

  13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA

  Statistical Editor, International Journal of Nursing Studies

  phone: +1.813.974.7667  fax: +1.813.974.4719          

  personal website:  http://personal.health.usf.edu/jbeckste/

  International Journal of Nursing Studies  http://www.elsevier.com/ijns

 

===================== 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: Pairs of Correlations Macro

David Marso-2
In reply to this post by Beckstead, Jason
Here is a non clunky way to do it.

DEFINE !corDMM(!POS !CHAREND("/") /!POS= !CMDEND)
!IF (!1 !NE !NULL) !THEN
CORRELATIONS
/VARIABLES = !HEAD(!1) !HEAD(!2).
!corDMM !TAIL(!1)/ !TAIL( !2).
!IFEND
!ENDDEFINE.

!corDMM a b c /  d e f.

Hello List Members,

I am attempting to write a macro to run several correlations. Specifically, I have two lists of variables, list1 and list2, and I want to get the correlations between variables that occupy the same position in the two lists.

For example, list1 is the variables X, Y, & Z, and list2 is the variables A, B, & C, and I only want to get these correlations (X,A), (Y,B), and, (Z,C).

I need this to work for a large number of variables (e.g., 20 in each list) when the variables are not consecutive in the file and are not subscripted.

I have tried specifying a macro with three arguments: one for the number of variables pairs, one referring to the first list, and one for the second list, but this does not work because I can't figure out how to use a loop to access the appropriate positions within each list.

 

Any suggestions?

 

Thanks in advance,

Jason

 

_____________________________________________________________

 Jason W. Beckstead, Ph.D.      

  Professor/Quantitative Methodologist

  University of South Florida College of Public Health

  13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA

  Statistical Editor, International Journal of Nursing Studies

  phone: +1.813.974.7667  fax: +1.813.974.4719          

  personal website:  http://personal.health.usf.edu/jbeckste/

  International Journal of Nursing Studies  http://www.elsevier.com/ijns

 

===================== 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
Reply | Threaded
Open this post in threaded view
|

Re: Pairs of Correlations Macro

Jon Peck
Nice use of recursion, David.  Next you could post a MATRIX solution.

On Wed, Sep 4, 2019 at 1:29 PM David Marso <[hidden email]> wrote:
Here is a non clunky way to do it.

DEFINE !corDMM(!POS !CHAREND("/") /!POS= !CMDEND)
!IF (!1 !NE !NULL) !THEN
CORRELATIONS
/VARIABLES = !HEAD(!1) !HEAD(!2).
!corDMM !TAIL(!1)/ !TAIL( !2).
!IFEND
!ENDDEFINE.

!corDMM a b c /  d e f.

Hello List Members,

I am attempting to write a macro to run several correlations. Specifically, I have two lists of variables, list1 and list2, and I want to get the correlations between variables that occupy the same position in the two lists.

For example, list1 is the variables X, Y, & Z, and list2 is the variables A, B, & C, and I only want to get these correlations (X,A), (Y,B), and, (Z,C).

I need this to work for a large number of variables (e.g., 20 in each list) when the variables are not consecutive in the file and are not subscripted.

I have tried specifying a macro with three arguments: one for the number of variables pairs, one referring to the first list, and one for the second list, but this does not work because I can't figure out how to use a loop to access the appropriate positions within each list.



Any suggestions?



Thanks in advance,

Jason



_____________________________________________________________

 Jason W. Beckstead, Ph.D.       

  Professor/Quantitative Methodologist

  University of South Florida College of Public Health

  13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA

  Statistical Editor, International Journal of Nursing Studies

  phone: +1.813.974.7667  fax: +1.813.974.4719         

  personal website:  http://personal.health.usf.edu/jbeckste/

  International Journal of Nursing Studies  http://www.elsevier.com/ijns



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


--
Jon K Peck
[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: Pairs of Correlations Macro

Bruce Weaver
Administrator
Hear, hear!  Very nice indeed!  


Jon Peck wrote
> Nice use of recursion, David.  Next you could post a MATRIX solution.
>
> On Wed, Sep 4, 2019 at 1:29 PM David Marso &lt;

> Dmmugaspss@

> &gt; wrote:
>
>> Here is a non clunky way to do it.
>>
>> DEFINE !corDMM(!POS !CHAREND("/") /!POS= !CMDEND)
>> !IF (!1 !NE !NULL) !THEN
>> CORRELATIONS
>> /VARIABLES = !HEAD(!1) !HEAD(!2).
>> !corDMM !TAIL(!1)/ !TAIL( !2).
>> !IFEND
>> !ENDDEFINE.
>>
>> !corDMM a b c /  d e f.
>>
>> Hello List Members,
>>
>> I am attempting to write a macro to run several correlations.
>> Specifically, I have two lists of variables, list1 and list2, and I want
>> to
>> get the correlations between variables that occupy the same position in
>> the
>> two lists.
>>
>> For example, list1 is the variables X, Y, & Z, and list2 is the variables
>> A, B, & C, and I only want to get these correlations (X,A), (Y,B), and,
>> (Z,C).
>>
>> I need this to work for a large number of variables (e.g., 20 in each
>> list) when the variables are not consecutive in the file and are not
>> subscripted.
>>
>> I have tried specifying a macro with three arguments: one for the number
>> of variables pairs, one referring to the first list, and one for the
>> second
>> list, but this does not work because I can't figure out how to use a loop
>> to access the appropriate positions within each list.
>>
>>
>>
>> Any suggestions?
>>
>>
>>
>> Thanks in advance,
>>
>> Jason
>>
>>
>>
>> _____________________________________________________________
>>
>>  Jason W. Beckstead, Ph.D.
>>
>>   Professor/Quantitative Methodologist
>>
>>   University of South Florida College of Public Health
>>
>>   13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA
>>
>>   Statistical Editor, International Journal of Nursing Studies
>>
>>   phone: +1.813.974.7667  fax: +1.813.974.4719
>>
>>   personal website:  http://personal.health.usf.edu/jbeckste/
>>
>>   International Journal of Nursing Studies  http://www.elsevier.com/ijns
>>
>>
>>
>> ===================== To manage your subscription to SPSSX-L, send a
>> message to

> LISTSERV@.UGA

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

> LISTSERV@.UGA

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

> LISTSERV@.UGA

>  (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
>>
>
>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
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
--
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: Pairs of Correlations Macro

bdates

This process can be used to pair variables for any comparison. David posted a macro using recursion on Dec. 11, 2013, which computes both correlations and one-way anova.


DEFINE DoSomething (!POS !CMDEND).
CORRELATION !HEAD(!1) WITH !TAIL(!1) .
!ENDDEFINE .

DEFINE DoSomethingElse (!POS !CMDEND).
ONEWAY !HEAD(!1) BY !TAIL(!1) .
!ENDDEFINE .

DEFINE Parallel
  (!POS !CHAREND ("/") / !POS !CHAREND ("/") / !POS !CMDEND ).
!UNQUOTE(!1) !HEAD(!2) !HEAD(!3) .
!IF (!TAIL(!2) !NE !NULL) !THEN
Parallel !1 / !TAIL(!2) / !TAIL(!3).
!IFEND
!ENDDEFINE.

DATA LIST FREE / a b c d e f.
BEGIN DATA
1 2 3 2 3 4
5 6 7 8 9 1
2 3 4 5 1 2
3 3 5 6 7 8
END DATA.
Parallel 'DoSomething' /a b c /d e f.
Parallel 'DoSomethingElse' /a b c /d e f.

For the correlations, you only need the first Define-!enddefine, the sample data, and the macro call line.


DEFINE DoSomething (!POS !CMDEND).
CORRELATION !HEAD(!1) WITH !TAIL(!1) .
!ENDDEFINE .
DATA LIST FREE / a b c d e f.
BEGIN DATA
1 2 3 2 3 4
5 6 7 8 9 1
2 3 4 5 1 2
3 3 5 6 7 8
END DATA.
Parallel 'DoSomething' /a b c /d e f.

Brian

From: SPSSX(r) Discussion <[hidden email]> on behalf of Bruce Weaver <[hidden email]>
Sent: Wednesday, September 4, 2019 4:01:07 PM
To: [hidden email] <[hidden email]>
Subject: Re: Pairs of Correlations Macro
 
Hear, hear!  Very nice indeed! 


Jon Peck wrote
> Nice use of recursion, David.  Next you could post a MATRIX solution.
>
> On Wed, Sep 4, 2019 at 1:29 PM David Marso &lt;

> Dmmugaspss@

> &gt; wrote:
>
>> Here is a non clunky way to do it.
>>
>> DEFINE !corDMM(!POS !CHAREND("/") /!POS= !CMDEND)
>> !IF (!1 !NE !NULL) !THEN
>> CORRELATIONS
>> /VARIABLES = !HEAD(!1) !HEAD(!2).
>> !corDMM !TAIL(!1)/ !TAIL( !2).
>> !IFEND
>> !ENDDEFINE.
>>
>> !corDMM a b c /  d e f.
>>
>> Hello List Members,
>>
>> I am attempting to write a macro to run several correlations.
>> Specifically, I have two lists of variables, list1 and list2, and I want
>> to
>> get the correlations between variables that occupy the same position in
>> the
>> two lists.
>>
>> For example, list1 is the variables X, Y, & Z, and list2 is the variables
>> A, B, & C, and I only want to get these correlations (X,A), (Y,B), and,
>> (Z,C).
>>
>> I need this to work for a large number of variables (e.g., 20 in each
>> list) when the variables are not consecutive in the file and are not
>> subscripted.
>>
>> I have tried specifying a macro with three arguments: one for the number
>> of variables pairs, one referring to the first list, and one for the
>> second
>> list, but this does not work because I can't figure out how to use a loop
>> to access the appropriate positions within each list.
>>
>>
>>
>> Any suggestions?
>>
>>
>>
>> Thanks in advance,
>>
>> Jason
>>
>>
>>
>> _____________________________________________________________
>>
>>  Jason W. Beckstead, Ph.D.
>>
>>   Professor/Quantitative Methodologist
>>
>>   University of South Florida College of Public Health
>>
>>   13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA
>>
>>   Statistical Editor, International Journal of Nursing Studies
>>
>>   phone: +1.813.974.7667  fax: +1.813.974.4719
>>
>>   personal website:  http://personal.health.usf.edu/jbeckste/
>>
>>   International Journal of Nursing Studies  http://www.elsevier.com/ijns
>>
>>
>>
>> ===================== To manage your subscription to SPSSX-L, send a
>> message to

> LISTSERV@.UGA

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

> LISTSERV@.UGA

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

> LISTSERV@.UGA

>  (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
>>
>
>
> --
> Jon K Peck

> jkpeck@

>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
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
===================== 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: Pairs of Correlations Macro

Kirill Orlov
In reply to this post by David Marso-2
I like David's idea of recursive macros. Without irony, Jon.
At least, it is creative. Often probably useful.

04.09.2019 22:29, David Marso пишет:
> DEFINE !corDMM(!POS !CHAREND("/") /!POS= !CMDEND)
> !IF (!1 !NE !NULL) !THEN
> CORRELATIONS
> /VARIABLES = !HEAD(!1) !HEAD(!2).
> !corDMM !TAIL(!1)/ !TAIL( !2).
> !IFEND
> !ENDDEFINE.
>
> !corDMM a b c /  d e f.

=====================
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: Pairs of Correlations Macro

spss.giesel@yahoo.de
In reply to this post by Bruce Weaver
Small correction: A pair of parentheses were missing ...

DEFINE !cor(list1 = !CHAREND("/") /list2 = !CMDEND)
!LET !n1 = !NULL /*counter for list 1*/
!DO !var1 !IN (!list1)
!LET !n1 = !CONCAT(!n1,1)
!LET !n2 = !NULL /*counter for list 2*/
!DO !var2 !IN (!list2)
!LET !n2 = !CONCAT(!n2,1)
!IF (!LENGTH(!n1) !EQ !LENGTH(!n2)) !THEN
CORRELATIONS
/VARIABLES = !var1 !var2
/PRINT=TWOTAIL NOSIG
/MISSING=PAIRWISE.
!IFEND
!DOEND
!DOEND
!ENDDEFINE.



Mario Giesel
Munich, Germany


Am Donnerstag, 5. September 2019, 02:10:58 MESZ hat Bruce Weaver <[hidden email]> Folgendes geschrieben:


Hear, hear!  Very nice indeed! 


Jon Peck wrote
> Nice use of recursion, David.  Next you could post a MATRIX solution.
>
> On Wed, Sep 4, 2019 at 1:29 PM David Marso &lt;

> Dmmugaspss@

> &gt; wrote:
>
>> Here is a non clunky way to do it.
>>
>> DEFINE !corDMM(!POS !CHAREND("/") /!POS= !CMDEND)
>> !IF (!1 !NE !NULL) !THEN
>> CORRELATIONS
>> /VARIABLES = !HEAD(!1) !HEAD(!2).
>> !corDMM !TAIL(!1)/ !TAIL( !2).
>> !IFEND
>> !ENDDEFINE.
>>
>> !corDMM a b c /  d e f.
>>
>> Hello List Members,
>>
>> I am attempting to write a macro to run several correlations.
>> Specifically, I have two lists of variables, list1 and list2, and I want
>> to
>> get the correlations between variables that occupy the same position in
>> the
>> two lists.
>>
>> For example, list1 is the variables X, Y, & Z, and list2 is the variables
>> A, B, & C, and I only want to get these correlations (X,A), (Y,B), and,
>> (Z,C).
>>
>> I need this to work for a large number of variables (e.g., 20 in each
>> list) when the variables are not consecutive in the file and are not
>> subscripted.
>>
>> I have tried specifying a macro with three arguments: one for the number
>> of variables pairs, one referring to the first list, and one for the
>> second
>> list, but this does not work because I can't figure out how to use a loop
>> to access the appropriate positions within each list.
>>
>>
>>
>> Any suggestions?
>>
>>
>>
>> Thanks in advance,
>>
>> Jason
>>
>>
>>
>> _____________________________________________________________
>>
>>  Jason W. Beckstead, Ph.D.
>>
>>  Professor/Quantitative Methodologist
>>
>>  University of South Florida College of Public Health
>>
>>  13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA
>>
>>  Statistical Editor, International Journal of Nursing Studies
>>
>>  phone: +1.813.974.7667  fax: +1.813.974.4719
>>
>>  personal website:  http://personal.health.usf.edu/jbeckste/
>>
>>  International Journal of Nursing Studies  http://www.elsevier.com/ijns
>>
>>
>>
>> ===================== 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
>>
>
>
> --
> Jon K Peck

> jkpeck@

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





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
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
===================== 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: Pairs of Correlations Macro

Rich Ulrich
In reply to this post by Beckstead, Jason
My internet-esp suggests that the two lists have versions of
the same variables, and so you might be very happy with using
the t-test command, for PAIRS=  . 

And even the variables do not represent two versions of the
same variable, which the paired t-test is appropriate for, you
will get a moderately compact list of the correlations.

--
Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of Beckstead, Jason <[hidden email]>
Sent: Wednesday, September 4, 2019 2:05 PM
To: [hidden email] <[hidden email]>
Subject: Pairs of Correlations Macro
 

Hello List Members,

I am attempting to write a macro to run several correlations. Specifically, I have two lists of variables, list1 and list2, and I want to get the correlations between variables that occupy the same position in the two lists.

For example, list1 is the variables X, Y, & Z, and list2 is the variables A, B, & C, and I only want to get these correlations (X,A), (Y,B), and, (Z,C).

I need this to work for a large number of variables (e.g., 20 in each list) when the variables are not consecutive in the file and are not subscripted.

I have tried specifying a macro with three arguments: one for the number of variables pairs, one referring to the first list, and one for the second list, but this does not work because I can't figure out how to use a loop to access the appropriate positions within each list.

 

Any suggestions?

 

Thanks in advance,

Jason

 

_____________________________________________________________

 Jason W. Beckstead, Ph.D.       

  Professor/Quantitative Methodologist

  University of South Florida College of Public Health

  13201 Bruce B. Downs Blvd., MDC56, Tampa, FL 33612, USA

  Statistical Editor, International Journal of Nursing Studies

  phone: +1.813.974.7667  fax: +1.813.974.4719          

  personal website:  http://personal.health.usf.edu/jbeckste/

  International Journal of Nursing Studies  http://www.elsevier.com/ijns

 

===================== 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: Pairs of Correlations Macro

Bruce Weaver
Administrator
Yes, well spotted, Rich.  Here are some examples from the FM:

T-TEST  PAIRS=TEACHER CONSTRUC MANAGER.
T-TEST  PAIRS=TEACHER MANAGER WITH CONSTRUC ENGINEER.
T-TEST  PAIRS=TEACHER MANAGER WITH CONSTRUC ENGINEER (PAIRED).

* The first T-TEST compares TEACHER with CONSTRUC, TEACHER with MANAGER, and
CONSTRUC with MANAGER.
* The second T-TEST compares TEACHER with CONSTRUC, TEACHER with ENGINEER,
MANAGER with CONSTRUC, and MANAGER with ENGINEER. TEACHER is not compared
with MANAGER, and CONSTRUC is not compared with ENGINEER.
* The third T-TEST compares TEACHER with CONSTRUC and MANAGER with ENGINEER.

Source:
https://www.ibm.com/support/knowledgecenter/en/SSLVMB_26.0.0/statistics_reference_project_ddita/spss/base/syn_t-test_pairs.html#syn_t-test_pairs

One could also use OMS to suppress all of the unwanted t-test output.  I
don't have SPSS here, so can't test an example right now, but I think it
would be something like this:

OMS /IF COMMANDS = ['t-test']
    /SELECT ALL EXCEPT = ['Paired Samples Correlations']
    /DESTINATION VIEWER = NO
    /TAG = 'CorrOnly'.

T-TEST  PAIRS=X Y Z WITH A B C (PAIRED).

OMSEND TAG = 'CorrOnly'.

If no one else checks it first, I'll try this tomorrow when I'm back in the
office.  

Once again, well spotted, Rich.



Rich Ulrich wrote

> My internet-esp suggests that the two lists have versions of
> the same variables, and so you might be very happy with using
> the t-test command, for PAIRS=  .
>
> And even the variables do not represent two versions of the
> same variable, which the paired t-test is appropriate for, you
> will get a moderately compact list of the correlations.
>
> --
> Rich Ulrich





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
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
--
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: Pairs of Correlations Macro

Bruce Weaver
Administrator
This post was updated on .
Here's a tested version that works.

DATA LIST LIST / X Y Z A B C (6F5.0).
BEGIN DATA
2 5 4 7 3 9
8 3 5 4 6 7
1 2 3 4 5 6
6 5 4 3 2 1
END DATA.

OMS
  /SELECT TABLES
  /IF COMMANDS=['T-Test'] SUBTYPES=['Paired Samples Statistics' 'Paired
Samples Test']
  /DESTINATION VIEWER=NO
  /TAG = 'CorrOnly'.

T-TEST  PAIRS=X Y Z WITH A B C (PAIRED).

OMSEND TAG = 'CorrOnly'.


OUTPUT (pivot table copied as plain text):

Paired Samples Correlations
                      N   Correlation    Sig.
Pair 1  X & A     4     -.495       .505
Pair 2  Y & B     4     -.852       .148
Pair 3  Z & C     4      .120       .880


One added benefit of this approach is that the results are in a single
table.  






Bruce Weaver wrote
> Yes, well spotted, Rich.  Here are some examples from the FM:
>
> T-TEST  PAIRS=TEACHER CONSTRUC MANAGER.
> T-TEST  PAIRS=TEACHER MANAGER WITH CONSTRUC ENGINEER.
> T-TEST  PAIRS=TEACHER MANAGER WITH CONSTRUC ENGINEER (PAIRED).
>
> * The first T-TEST compares TEACHER with CONSTRUC, TEACHER with MANAGER,
> and
> CONSTRUC with MANAGER.
> * The second T-TEST compares TEACHER with CONSTRUC, TEACHER with ENGINEER,
> MANAGER with CONSTRUC, and MANAGER with ENGINEER. TEACHER is not compared
> with MANAGER, and CONSTRUC is not compared with ENGINEER.
> * The third T-TEST compares TEACHER with CONSTRUC and MANAGER with
> ENGINEER.
>
> Source:
> https://www.ibm.com/support/knowledgecenter/en/SSLVMB_26.0.0/statistics_reference_project_ddita/spss/base/syn_t-test_pairs.html#syn_t-test_pairs
>
> One could also use OMS to suppress all of the unwanted t-test output.  I
> don't have SPSS here, so can't test an example right now, but I think it
> would be something like this:
>
> OMS /IF COMMANDS = ['t-test']
>     /SELECT ALL EXCEPT = ['Paired Samples Correlations']
>     /DESTINATION VIEWER = NO
>     /TAG = 'CorrOnly'.
>
> T-TEST  PAIRS=X Y Z WITH A B C (PAIRED).
>
> OMSEND TAG = 'CorrOnly'.
>
> If no one else checks it first, I'll try this tomorrow when I'm back in
> the
> office.  
>
> Once again, well spotted, Rich.
>
>
>
> Rich Ulrich wrote
>> My internet-esp suggests that the two lists have versions of
>> the same variables, and so you might be very happy with using
>> the t-test command, for PAIRS=  .
>>
>> And even the variables do not represent two versions of the
>> same variable, which the paired t-test is appropriate for, you
>> will get a moderately compact list of the correlations.
>>
>> --
>> Rich Ulrich
>
>
>
>
>
> -----
> --
> Bruce Weaver

> bweaver@

> http://sites.google.com/a/lakeheadu.ca/bweaver/
>
> "When all else fails, RTFM."
>
> NOTE: My Hotmail account is not monitored regularly.
> To send me an e-mail, please use the address shown above.
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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





-----
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
--
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: Pairs of Correlations Macro

David Marso-2
In reply to this post by Beckstead, Jason
Still ultra klunky Mario.

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