LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2005)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 1 Sep 2005 16:12:48 -0500
Reply-To:     Vishal Dave <VishalDave@Affina.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Vishal Dave <VishalDave@Affina.com>
Subject:      Re: Position in the ramking to new variables
Content-Type: text/plain; charset="iso-8859-1"

Victor,

Try below syntax.

I have created macro for generalizing this problem. It works for as many variables as possible as long as it follows the naming convention of varname(n). The macro calls for four variables x1 to x4. It also considers cases with equal variables and missing values. Missing values are taken as lowest value, which can be recoded back to missing after running this macro.

*******************************************************************

SET MPRINT ON PRINTBACK ON. DATA LIST LIST (",") /x1 x2 x3 x4. BEGIN DATA 5, 3, 72, 8 2, 1, 4, 3 1, 2, 3, 5 1, 1, 1, 1 2, 3, 2, 2 , 1,,1 END DATA.

DEFINE !rank(nbvars=!TOKENS(1) /v1=!TOKENS(1) /v2=!TOKENS(1)) VECTOR y(!nbvars,F3). VECTOR v=!v1 TO !v2 /#val(!nbvars). LOOP #cnt=1 TO !nbvars. - COMPUTE #val(#cnt)=v(#cnt). END LOOP. LOOP #cnt1 = 1 TO !nbvars. - COMPUTE y(#cnt1) = 1. - LOOP #cnt2 = 1 to !nbvars. - IF (#val(#cnt1) > v(#cnt2)) y(#cnt1) = y(#cnt1) + 1. - END LOOP. END LOOP. !ENDDEFINE. !rank nbvars=4 v1=x1 v2=x4. EXECUTE.

*********************************************************************

Hope this helps,

Vishal.

-----Original Message----- From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of Victor Tarrago Sent: Thursday, September 01, 2005 12:02 PM To: SPSSX-L@LISTSERV.UGA.EDU Subject: Position in the ramking to new variables

Dear list,

We have a "big" problem and we would like to solve it with SPSS. We have 4 different variables (4 channels - x1, x2, x3 and x4) with utility values and we would like to create 4 new variables (one for each channel - y1, y2, y3 and y4) which value has to be the order of each channel in the ranking based on the utilities for each case.

Considering only two cases, we have something like this:

X1 X2 X3 X4 Case 1 5 3 72 8 Case 2 1 7 4 16

And we would like to obtain something like this:

y1 y2 y3 Y4 Case 1 2 1 4 3 Case 2 1 3 2 4

How can we get it? Thank you for your response.

Victor Tarragó Sanromà Acziona Quanlitative Market Consultants Tel. + 34 93.238.43.53 Fax. + 34 93.238.45.99 vtarrago@acziona.com www.acziona.com ------------------------------------------------------------------- Important Notice This communication contains information which is confidential and/or privileged and may not necessarily represent the opinion of ACZIONA. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please remind that any distribution, copying or use of this communication or the information in it, is strictly prohibited. If you have received this communication in error please notify us immediately by email and then delete this message and any copies of it. Aviso Importante Este comunicado contiene información confidencial y/o privilegiada y no necesariamente refleja la opinión de ACZIONA. Es para uso exclusivo de su destinatario. Si usted no es su destinatario, tenga en consideración que cualquier acción de distribución, copia o uso total o parcial de esta comunicación o de la información que contiene está estrictamente prohibida. Si usted recibe el mensaje por error, por favor comuníqueselo inmediatamente al remitente a través del e-mail y elimine este mensaje o a cualquier copia de este.


Back to: Top of message | Previous page | Main SPSSX-L page