|
Hi,
Is there a function or code similar to vlookup in excel. I have two columns of data, for example 1 2 2 5 3 7 4 8 5 0 6 21 7 41 9 12 14 1 16 14 20 18 I would like to create a third column that would return the value in the first column if the number was contained in both columns 1 and 2. For example, in the first column first row the number is 1. Since there is a 1 in the second column it should return 1 in the new column first row. If there was no 1 in the second column, maybe return missing or N/A. Thank you very much for any help with this.. ====================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 |
|
There is a function called lookup in the extendedTransforms.py programmability module available from SPSS Developer Central (www.spss.com/devcentral). It works much like Excel vlookup but does not have the sorting requirement of that function. You would have to initialize it with the appropriate case data.
Otherwise, you could work this out with a TABLE-type match using a second copy of the dataset and some sorting. HTH, Jon Peck -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Keval Khichadia Sent: Tuesday, June 24, 2008 6:56 PM To: [hidden email] Subject: [SPSSX-L] finding matching cases in columns Hi, Is there a function or code similar to vlookup in excel. I have two columns of data, for example 1� � � 2 2� � � 5 3� � � 7 4� � � 8 5� � � 0 6� � � 21 7� � � 41 9� � � 12 14� 1 16� 14 20� 18 I would like to create a third column that would return� the value in the first column� if the number was contained in both columns 1 and 2. For example, in the first column first row the number is 1. Since there is a 1 in the second column it should return 1 in the new column first row. If there was no 1 in the second column, maybe return missing or N/A. Thank you very much� for any help with this.. ======= 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 ===================== 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 |
|
In reply to this post by Keval Khichadia
* Think this is all you need:
Match = Var1 if match 0 if not match missing if either Var1 or Var2 missing . COMPUTE Match = (Var1 = Var2) * Var1 . Dennis Deck, PhD RMC Research Corporation 111 SW Columbia Street, Suite 1200 Portland, Oregon 97201-5843 voice: 503-223-8248 x715 voice: 800-788-1887 x715 fax: 503-223-8248 [hidden email] -----Original Message----- From: Keval Khichadia [mailto:[hidden email]] Sent: Tuesday, June 24, 2008 5:56 PM Subject: finding matching cases in columns Hi, Is there a function or code similar to vlookup in excel. I have two columns of data, for example 1 2 2 5 3 7 4 8 5 0 6 21 7 41 9 12 14 1 16 14 20 18 I would like to create a third column that would return the value in the first column if the number was contained in both columns 1 and 2. For example, in the first column first row the number is 1. Since there is a 1 in the second column it should return 1 in the new column first row. If there was no 1 in the second column, maybe return missing or N/A. Thank you very much for any help with this.. ===================== 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 |
| Free forum by Nabble | Edit this page |
