Visual Binning alternatives?

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

Visual Binning alternatives?

David Wade

I’m using version 17 of SPSS.

 

I have a large data file with raw scores I’ve recoded into levels based on another variable.

 

My example;

 

DO IF  (gradelevel=3).

RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.

EXECUTE.

 

As you can see, each range of values varies in length, and I’ve attempted to use visual binning to obtain a further breakdown of each level into equal thirds, but since each level range is different I’m having difficulty getting the coding to work clearly. To make matters more difficult, the range is different for each DO IF I have, and I have four sets of ranges for 8 different sets of data.

 

Mathematically it would look like;

 

643-475 = 168/3 = 56 points in each mini-range

so then

475 thru 531=1 low

532 thru 587 =1 medium

588 thru 643 = 1 high

 

And I would do this for each range by plugging in just the initial range of values.

 

Is there syntax I can use that would give me my level ranges in equal thirds so all I have to do is plug in the ranges and let the syntax do the rest?

 

-David 

 

Reply | Threaded
Open this post in threaded view
|

Re: Visual Binning alternatives?

Marks, Jim

You can use RANK to get percentile scores.

 

RANK also accepts a BY subcommand to get ranks within a variable.

 

Not able to write code this am, so I’m not sure this will do everything you need.

 

Jim Marks

Director, Market Research

x1616

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Wade
Sent: Tuesday, November 08, 2011 8:57 AM
To: [hidden email]
Subject: Visual Binning alternatives?

 

I’m using version 17 of SPSS.

 

I have a large data file with raw scores I’ve recoded into levels based on another variable.

 

My example;

 

DO IF  (gradelevel=3).

RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.

EXECUTE.

 

As you can see, each range of values varies in length, and I’ve attempted to use visual binning to obtain a further breakdown of each level into equal thirds, but since each level range is different I’m having difficulty getting the coding to work clearly. To make matters more difficult, the range is different for each DO IF I have, and I have four sets of ranges for 8 different sets of data.

 

Mathematically it would look like;

 

643-475 = 168/3 = 56 points in each mini-range

so then

475 thru 531=1 low

532 thru 587 =1 medium

588 thru 643 = 1 high

 

And I would do this for each range by plugging in just the initial range of values.

 

Is there syntax I can use that would give me my level ranges in equal thirds so all I have to do is plug in the ranges and let the syntax do the rest?

 

-David 

 

Reply | Threaded
Open this post in threaded view
|

Re: Visual Binning alternatives?

Art Kendall
In reply to this post by David Wade

try something like this.
DO IF  (gradelevel eq 3).

RECODE testscore (SYSMIS=-1) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.
missing values testscorelevel (lo thru -1).

rank
 variables = whatever by testscorelevel
 /ntiles(3) into somenewvar.


How do you get your values that define testscorelevel? Are they ntiles?


Art Kendall
Social Research Consultants



On 11/8/2011 9:57 AM, David Wade wrote:

I’m using version 17 of SPSS.

 

I have a large data file with raw scores I’ve recoded into levels based on another variable.

 

My example;

 

DO IF  (gradelevel=3).

RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.

EXECUTE.

 

As you can see, each range of values varies in length, and I’ve attempted to use visual binning to obtain a further breakdown of each level into equal thirds, but since each level range is different I’m having difficulty getting the coding to work clearly. To make matters more difficult, the range is different for each DO IF I have, and I have four sets of ranges for 8 different sets of data.

 

Mathematically it would look like;

 

643-475 = 168/3 = 56 points in each mini-range

so then

475 thru 531=1 low

532 thru 587 =1 medium

588 thru 643 = 1 high

 

And I would do this for each range by plugging in just the initial range of values.

 

Is there syntax I can use that would give me my level ranges in equal thirds so all I have to do is plug in the ranges and let the syntax do the rest?

 

-David 

 

===================== 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Visual Binning alternatives?

David Marso
Administrator
In reply to this post by David Wade
David,
Totally untested but general idea follows (you may need to do some fine tuning):
---
VECTOR #Range(5).
DO REPEAT #=1 TO 5 / R=475 643 662 694 780.
COMPUTE #Range(#)=R.
EMD REPEAT.
LOOP #=1 TO 4.
+  LOOP ##=0 TO 3.
+    COMPUTE #LO=#Range(#) + (#Range(#+1)-#Range(#))/3 * ## .
+    COMPUTE #HI=#Range(#) + (#Range(#+1)-#Range(#))/3 *(##+1).
+    COMPUTE NewVar=Range(OldVar,#LO,#HI) * (#-1)*3 + ##+1.
+  END LOOP.
END LOOP.

--- Could turn it into a MACRO and just feed it values. Again untested!!!
DEFINE SliceIt (OldVar =!TOKENS(1)
                    / NewVar =!TOKENS(1)
                   / Ranges !CMDEND ) .
VECTOR #Range(5).
DO REPEAT #=1 TO 5 / R=!Ranges ,
COMPUTE #Range(#)=R.
EMD REPEAT.
LOOP #=1 TO 4.
+  LOOP ##=0 TO 3.
+    COMPUTE #LO=#Range(#) + (#Range(#+1)-#Range(#))/3 * ## .
+    COMPUTE #HI=#Range(#) + (#Range(#+1)-#Range(#))/3 *(##+1).
+    COMPUTE !NewVar=Range(!OldVar,#LO,#HI) * (#-1)*3 + ##+1.
+  END LOOP.
END LOOP.
EXECUTE.
!ENDDEFINE .

SliceIt NewVar= MyNewVar OldVar=MyOldVar Ranges 475 643 662 694 780 .


David Wade wrote
I'm using version 17 of SPSS.

 

I have a large data file with raw scores I've recoded into levels based
on another variable.

 

My example;

 

DO IF  (gradelevel=3).

RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.

EXECUTE.

 

As you can see, each range of values varies in length, and I've
attempted to use visual binning to obtain a further breakdown of each
level into equal thirds, but since each level range is different I'm
having difficulty getting the coding to work clearly. To make matters
more difficult, the range is different for each DO IF I have, and I have
four sets of ranges for 8 different sets of data.

 

Mathematically it would look like;

 

643-475 = 168/3 = 56 points in each mini-range

so then

475 thru 531=1 low

532 thru 587 =1 medium

588 thru 643 = 1 high

 

And I would do this for each range by plugging in just the initial range
of values.

 

Is there syntax I can use that would give me my level ranges in equal
thirds so all I have to do is plug in the ranges and let the syntax do
the rest?

 

-David
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: Visual Binning alternatives?

John F Hall
In reply to this post by David Wade

Complex answers already provided by others, but if you only want two cut-points, a simple quick check is to use:

 

temp.

select if gradelevel = 3.

freq testscore /for not/ per 33.3 66.7.

 

You can then use the cut-points in your RECODE command.

 

 

John F Hall

 

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David Wade
Sent: 08 November 2011 15:57
To: [hidden email]
Subject: Visual Binning alternatives?

 

I’m using version 17 of SPSS.

 

I have a large data file with raw scores I’ve recoded into levels based on another variable.

 

My example;

 

DO IF  (gradelevel=3).

RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.

EXECUTE.

 

As you can see, each range of values varies in length, and I’ve attempted to use visual binning to obtain a further breakdown of each level into equal thirds, but since each level range is different I’m having difficulty getting the coding to work clearly. To make matters more difficult, the range is different for each DO IF I have, and I have four sets of ranges for 8 different sets of data.

 

Mathematically it would look like;

 

643-475 = 168/3 = 56 points in each mini-range

so then

475 thru 531=1 low

532 thru 587 =1 medium

588 thru 643 = 1 high

 

And I would do this for each range by plugging in just the initial range of values.

 

Is there syntax I can use that would give me my level ranges in equal thirds so all I have to do is plug in the ranges and let the syntax do the rest?

 

-David 

 

Reply | Threaded
Open this post in threaded view
|

Re: Visual Binning alternatives?

Bruce Weaver
Administrator
In reply to this post by David Wade
David, I am curious about why you want to convert scores into ranges.  What is the research question, and what form of analysis are you planning on using?

Thanks,
Bruce


David Wade wrote
I'm using version 17 of SPSS.

I have a large data file with raw scores I've recoded into levels based
on another variable.

My example;

DO IF  (gradelevel=3).

RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.

EXECUTE.
 

As you can see, each range of values varies in length, and I've
attempted to use visual binning to obtain a further breakdown of each
level into equal thirds, but since each level range is different I'm
having difficulty getting the coding to work clearly. To make matters
more difficult, the range is different for each DO IF I have, and I have
four sets of ranges for 8 different sets of data.
 
Mathematically it would look like;

643-475 = 168/3 = 56 points in each mini-range

so then

475 thru 531=1 low

532 thru 587 =1 medium

588 thru 643 = 1 high

 
And I would do this for each range by plugging in just the initial range
of values.

Is there syntax I can use that would give me my level ranges in equal
thirds so all I have to do is plug in the ranges and let the syntax do
the rest?

-David
--
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: Visual Binning alternatives?

David Wade

Bruce,

 

These are assessment test scores, and I’m doing some plain old recoding into new variables for simple frequency analysis.

 

We get a list of the possible raw scores with a level range as such (this set is from 2010-2011 and next year will change completely);

 

Gradelevel

Level 1

Level 2

Level 3

Level 4

3

475-643

644-662

663-693

694-780

4

430-636

637-670

671-721

722-775

5

495-647

648-667

668-699

700-795

6

480-643

644-661

662-693

694-785

7

470-641

642-664

665-697

698-790

8

430-627

628-657

658-698

699-790

 

My data looks like this (except I have around 30,000 rows);

 

Case

TestScore

Gradelevel

1

450

8

2

555

4

3

650

3

4

780

3

5

620

6

6

430

8

7

680

8

 

So my basic recode will designate the levels (1-4), with a different DO IF by grade level.

 

DO IF  (gradelevel=3).

RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

(663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

END IF.

EXECUTE.

 

Case

TestScore

Gradelevel

Testscorelevel

1

450

8

1

2

555

4

1

3

650

3

2

4

780

3

4

5

620

6

1

6

430

8

1

7

680

8

3

 

Some of our clients want each possible range to be split into 1/3rds so I’d have a Low/Medium/High designation within each range. Now I can do this mathematically, and build a recode for each grade level.

 

I was hoping to find a quicker route to reach those thirds without having to build a new recode every year (since the initial level ranges change each year). I was going to roll over syntax and just plug in the provided level ranges and let the syntax do the rest each year.

 

The ntiles command has not worked out for me because it bases those .33 and .66 splits on the range of existing values and not my predefined range.

 

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Bruce Weaver
Sent: Tuesday, November 08, 2011 3:01 PM
To: [hidden email]
Subject: Re: Visual Binning alternatives?

 

David, I am curious about why you want to convert scores into ranges.  What

is the research question, and what form of analysis are you planning on

using?

 

Thanks,

Bruce

 

 

 

David Wade wrote:

> 

> I'm using version 17 of SPSS.

> 

> I have a large data file with raw scores I've recoded into levels based

> on another variable.

> 

> My example;

> 

> DO IF  (gradelevel=3).

> 

> RECODE testscore (SYSMIS=SYSMIS) (475 thru 643=1) (644 thru 662=2)

> 

> (663 thru 693=3) (694 thru 780=4) INTO testscorelevel.

> 

> END IF.

> 

> EXECUTE.

> 

> 

> As you can see, each range of values varies in length, and I've

> attempted to use visual binning to obtain a further breakdown of each

> level into equal thirds, but since each level range is different I'm

> having difficulty getting the coding to work clearly. To make matters

> more difficult, the range is different for each DO IF I have, and I have

> four sets of ranges for 8 different sets of data.

> 

> Mathematically it would look like;

> 

> 643-475 = 168/3 = 56 points in each mini-range

> 

> so then

> 

> 475 thru 531=1 low

> 

> 532 thru 587 =1 medium

> 

> 588 thru 643 = 1 high

> 

> 

> And I would do this for each range by plugging in just the initial range

> of values.

> 

> Is there syntax I can use that would give me my level ranges in equal

> thirds so all I have to do is plug in the ranges and let the syntax do

> the rest?

> 

> -David

> 

 

 

-----

--

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.

 

--

View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Visual-Binning-alternatives-tp4974525p4975464.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

Reply | Threaded
Open this post in threaded view
|

Re: Visual Binning alternatives?

David Marso
Administrator
In reply to this post by David Marso
OOPS!!!
That should actually be:
(Otherwise you will get a bunch of zeros ;-(
David,
Totally untested but general idea follows (you may need to do some fine tuning):
---
VECTOR #Range(5).
DO REPEAT #=1 TO 5 / R=475 643 662 694 780.
COMPUTE #Range(#)=R.
EMD REPEAT.
LOOP #=1 TO 4.
+  LOOP ##=0 TO 3.
+    COMPUTE #LO=#Range(#) + (#Range(#+1)-#Range(#))/3 * ## .
+    COMPUTE #HI=#Range(#) + (#Range(#+1)-#Range(#))/3 *(##+1).
+    IF RANGE(OldVar,#LO,#HI)  NewVar= (#-1)*3 + ##+1.
+  END LOOP.
END LOOP.

--- Could turn it into a MACRO and just feed it values. Again untested!!!
DEFINE SliceIt (OldVar =!TOKENS(1)
                    / NewVar =!TOKENS(1)
                   / Ranges !CMDEND ) .
VECTOR #Range(5).
DO REPEAT #=1 TO 5 / R=!Ranges ,
COMPUTE #Range(#)=R.
EMD REPEAT.
LOOP #=1 TO 4.
+  LOOP ##=0 TO 3.
+    COMPUTE #LO=#Range(#) + (#Range(#+1)-#Range(#))/3 * ## .
+    COMPUTE #HI=#Range(#) + (#Range(#+1)-#Range(#))/3 *(##+1).
+    IF Range(!OldVar,#LO,#HI)  !NewVar=(#-1)*3 + ##+1.
+  END LOOP.
END LOOP.
EXECUTE.
!ENDDEFINE .

SliceIt NewVar= MyNewVar OldVar=MyOldVar Ranges 475 643 662 694 780 .
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?"