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

Posted by Bruce Weaver on
URL: http://spssx-discussion.165.s1.nabble.com/How-to-compute-this-is-nth-time-name-occurred-in-a-list-tp5740792p5740793.html

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/).