SPSS 12 - Isolating the max value in a variable for use in syntax

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

SPSS 12 - Isolating the max value in a variable for use in syntax

fosh90
This post was updated on .
I have a table of areas with data. For a particular operation, I want to exclude the top and bottom 1% of areas, as they include extreme outliers.

Seems to me that a way forward is:

SORT CASES BY theVariableIwantToAnalyse (A) .

NUMERIC id (F12.0) . * create a casenum label "id"

COMPUTE id = $CASENUM. * populate it with casenum EXECUTE.

NUMERIC idmax (F12.4) . * create a variable to contain the highest value for "id"

NUMERIC id1perc (F12.4) . * create a variable to contain 1% of the highest value for "id"

COMPUTE idmax = MAX(id) . * determine the highest value for id. This 'mock-syntax' line does not work.

COMPUTE id1perc = idmax / 100 . * 1% of the highest value for "id"

SELECT CASES WHERE ID >= id1perc or ID <= idmax - id1perc .

Draw graphs etc.

... and yes that is SPSS 12 - ten years and ten versions out of date ...

Bruce Mitchell MA MSc ONS Geography | Office for National Statistics | PO15 5RR | UK bruce.mitchell@ons.gsi.gov.uk | +44(0) 1329 444455
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 12 - Isolating the max value in a variable for use in syntax

David Marso
Administrator
You are going about this completely wrong!
COMPUTE ...MAX() operates within a case, NOT an entire column.
See RANK to achieve this task! (NTILES or PERCENT will be useful).
----
fosh90 wrote
I have a table of areas with data. For a particular operation, I want to exclude the top and bottom 1% of areas, as they include extreme outliers.
</p><p>
Seems to me that a way forward is:
</p><p>
</p><p>
SORT CASES BY theVariableIwantToAnalyse (A) .
</p><p>
NUMERIC id (F12.0) . * create a casenum label "id"
</p><p>
COMPUTE id = $CASENUM. * populate it with casenum EXECUTE.
</p><p>
</p><p>
NUMERIC idmax (F12.4) . * create a variable to contain the highest value for "id"
</p><p>
NUMERIC id1perc (F12.4) . * create a variable to contain 1% of the highest value for "id"
</p><p>
</p><p>
COMPUTE idmax = MAX(id) . * determine the highest value for id. This 'mock-syntax' line does not work.
</p><p>
COMPUTE id1perc = idmax / 100 . * 1% of the highest value for "id"
</p><p>
</p><p>
SELECT CASES WHERE ID >= id1perc or ID <= idmax - id1perc .
</p><p>
Draw graphs etc.
</p><p>
</p><p>
... and yes that is SPSS 12 - ten years and ten versions out of date ...
</p><p>
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 12 - Isolating the max value in a variable for use in syntax

Andy W
In reply to this post by fosh90
In addition to David's advice, I could not tell if RANK was available for V12 (I presume it was), but you could also get the max and min id within an area using AGGREGATE. I might also suggest instead of throwing away data to winsorize the data, see http://en.wikipedia.org/wiki/Winsorising.

At least for graphs that should be sufficient, for other statistical procedures you have a whole lot of options (weighting, other robust stats. etc.).
Andy W
apwheele@gmail.com
http://andrewpwheeler.wordpress.com/
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 12 - Isolating the max value in a variable for use in syntax

David Marso
Administrator
RANK is as old as Nick!

Andy W wrote
In addition to David's advice, I could not tell if RANK was available for V12 (I presume it was), but you could also get the max and min id within an area using AGGREGATE. I might also suggest instead of throwing away data to winsorize the data, see http://en.wikipedia.org/wiki/Winsorising.

At least for graphs that should be sufficient, for other statistical procedures you have a whole lot of options (weighting, other robust stats. etc.).
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 12 - Isolating the max value in a variable for use in syntax

fosh90
In reply to this post by Andy W
Andy and Dave. Thank you. I did get it to work using RANK.
Bruce Mitchell MA MSc ONS Geography | Office for National Statistics | PO15 5RR | UK bruce.mitchell@ons.gsi.gov.uk | +44(0) 1329 444455