Re: sorting correlations

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: sorting correlations

John F Hall

Bruce

Perfect.  Mille fois merci.

John

 

GET FILE="H:\F drive backup\Research1a\4 Surveys\Quality of Life\QLGB1971-75\QL3\districtuk.sav".

DATASET NAME raw.

 

* OMS.

DATASET DECLARE  varinfo.

OMS

  /SELECT TABLES

  /TAG = "varinfo"

  /IF COMMANDS=['Sysfile Info'] SUBTYPES=['Variable Information']

  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_

   OUTFILE='varinfo' VIEWER=YES.

 

SYSFILE INFO raw.

 

OMSEND TAG = "varinfo".

DATASET ACTIVATE varinfo.

DELETE VARIABLES  TableNumber_ TO Subtype_ Position MeasurementLevel TO MissingValues.

* Change Var1 to A8 and rename it to VARNAME_ to make it match name & format in the next file.

ALTER TYPE Var1 (A8).

RENAME VARIABLES (Var1 Label = VARNAME_ varlabel).

 

 

DATASET ACTIVATE raw.

DATASET DECLARE  corrmat.

CORRELATIONS var235 TO var250

/MATRIX = OUT("corrmat").

 

DATASET ACTIVATE corrmat.

SELECT IF  ROWTYPE_ EQ "CORR" AND VARNAME_ NE "var250".

EXECUTE.

 

MATCH FILES FILE = "varinfo" /FILE= "corrmat" /BY VARNAME_.

EXECUTE.

DATASET NAME merged.

DATASET CLOSE varinfo.

DATASET CLOSE corrmat.

 

DATASET ACTIVATE merged.

SELECT IF ROWTYPE_ EQ "CORR".

COMPUTE absr = ABS(var250).

SORT CASES by absr(D).

 

VARIABLE LABELS varlabel "Variable".

FORMATS var250 (F8.4).

SUMMARIZE

  /TABLES=varlabel var250

  /FORMAT=LIST NOCASENUM

  /TITLE='Correlations with District'

  /MISSING=VARIABLE

  /CELLS=NONE.

 

 

Correlations with District

 

varlabel Variable

var250 C1:  Satisfaction with district

1

B1o:  PEOPLE

.6778

2

B1j:  APPEARANCE

.6699

3

B1n:  POLLUTION

.5605

4

B1k: SAFE at NIGHT

.5444

5

B1d:  NOISE

.5167

6

B1f:  CRIME

.4948

7

B1i:  TRAFFIC

.3981

8

B1a:  ROADS,PATHS

.3612

9

B1m:  NEAR FRIENDS

.3492

10

B1g:  SCHOOLS

.3273

11

B1h:  PARKS

.3261

12

B1e:  ENTERTAINMT

.3108

13

B1l:  NEAR FAMILY

.2875

14

B1c:  SHOPS

.2854

15

B1b:  TRANSPORT

.2257

 

 

From: Bruce Weaver <[hidden email]>
Sent: 22 July 2020 17:36
To: John F Hall <[hidden email]>
Subject: Re: sorting correlations

 

Here's a souped up version of what I posted previously, John.  It uses SYSFILE INFO in conjunction with OMS to grab the variable labels for use in the final table of (sorted) correlations.  NPR as I like to say.  I.e., No Python Required.*  I did not take time to comment extensively, but hope things are relatively clear nevertheless! 

 

* Jon P will never agree with me on this, but I really dislike the way IBM has gone to implementing so much new functionality via Python and R programmability rather than fixing and adding native SPSS commands. 

 

Cheers,

Bruce

 

 

 

On Wed, Jul 22, 2020 at 4:31 AM <[hidden email]> wrote:

 

Jon, Bruce

Here's an extract from the *.sav file for you to test your syntax

John



--

Bruce Weaver
Research Associate, Centre for Research on Safe Driving, Lakehead University
Assistant Professor of Biostatistics, Human Sciences Division
Northern Ontario School of Medicine, West Campus
955 Oliver Road, MS-2006, Thunder Bay, ON  P7B 5E1

Tel:   807-346-7704     Fax:  807-766-7362   
Email:  [hidden email]  
Web:   http://sites.google.com/a/lakeheadu.ca/bweaver/

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