How to compute this is nth time name occurred in a list?

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

How to compute this is nth time name occurred in a list?

Art Kendall
In  Get Priority.sps, I am trying to apply these directions
https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html
to  House2020.sav.

 In the SPSS syntax, I have a sorted variable “Priority” which is the priority in which a seat is the House of Representatives is assigned a seat.  So the first time Alabama occurs in the list it gets 1 assigned to “StateSeat”  the second time Alabama occurs it gets a 2 assigned to “StateSeat” and so forth for all 50 states.  The variable needed is “ this is the nth time the state occurred in the sorted list of priorities”.
Census Bureau’s results are shown in
2020PriorityValues.xlsx
Get_Priority.sps
House2020.sav
2020PriorityValues.xlsx

Any suggestions would be appreciated.
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: How to compute this is nth time name occurred in a list?

Bruce Weaver
Administrator
Hi Art.  If I follow, I think this gives what you're looking for, or at least the numeric part of it.  

SORT CASES BY State HouseSeat.
* Set Appearance = 1 on the first row for each State.
MATCH FILES FILE = * /BY State /FIRST=Appearance.
FORMATS Appearance (F5.0).
* Fill in the other values of Appearance.
IF Appearance EQ 0 Appearance = LAG(Appearance) + 1.
DESCRIPTIVES Appearance.
* Restore original sort order.
SORT CASES BY HouseSeat.


Art Kendall wrote
In  Get Priority.sps, I am trying to apply these directions
https://www.census.gov/topics/public-sector/congressional-apportionment/about/computing.html
to  House2020.sav.

 In the SPSS syntax, I have a sorted variable “Priority” which is the priority in which a seat is the House of Representatives is assigned a seat.  So the first time Alabama occurs in the list it gets 1 assigned to “StateSeat”  the second time Alabama occurs it gets a 2 assigned to “StateSeat” and so forth for all 50 states.  The variable needed is “ this is the nth time the state occurred in the sorted list of priorities”.
Census Bureau’s results are shown in
2020PriorityValues.xlsx
Get_Priority.sps
House2020.sav
2020PriorityValues.xlsx

Any suggestions would be appreciated.
--
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: How to compute this is nth time name occurred in a list?

Art Kendall
looks good.

That was quick! will give it a try first thing tomorrow . Dinner will be ready in 3 minutes.
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: How to compute this is nth time name occurred in a list?

Art Kendall
It did work.

I now have SPSS syntax that implements the apportionments of seats in the House Of Representatives. The results are identical to those produced by the Census Bureau.

Just need to work on making it more readable etc for sharing.
Art Kendall
Social Research Consultants