lookup in SPSS

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

lookup in SPSS

nidhigupta
Hi
I am a beginner in using SPSS.

I need to find
For Example in dataset below, for SN 1, i need to find the value of T1 to T7 which is closest to Value of variable 'Time'.
So for example, for row 1, the time is 2 hours, the closest time value from T1 to T7 is the time in T5, so the return value is T5


SN Time T1 T2 T3 T4 T5 T6 T7
1 2 0,5 0,6 0,7 1,4 2 5 6
2 3 1 2 3 4 6 5 7
3 4 1 1 2 3 4,7 6 8

Could you please help me write a syntax for it?
Regards
Nidhi
Reply | Threaded
Open this post in threaded view
|

Re: lookup in SPSS

Maguin, Eugene
Is this a possible case? If so, what is the correct choice?

57 7 1 4 2 3 4,7 6 8

Gene Maguin


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of nidhigupta
Sent: Thursday, October 02, 2014 9:12 AM
To: [hidden email]
Subject: lookup in SPSS

Hi
I am a beginner in using SPSS.

I need to find
For Example in dataset below, for SN 1, i need to find the value of T1 to T7 which is closest to Value of variable 'Time'.
So for example, for row 1, the time is 2 hours, the closest time value from
T1 to T7 is the time in T5, so the return value is T5


SN Time T1 T2 T3 T4 T5 T6 T7
1 2 0,5 0,6 0,7 1,4 2 5 6
2 3 1 2 3 4 6 5 7
3 4 1 1 2 3 4,7 6 8

Could you please help me write a syntax for it?
Regards
Nidhi



--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/lookup-in-SPSS-tp5727468.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

=====================
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: lookup in SPSS

David Marso
Administrator
In reply to this post by nidhigupta
Here is one approach:

DATA LIST LIST/SN Time T1 TO T7.
BEGIN DATA
1 2 0.5 0.6 0.7 1.4 2   5   6
2 3 1   2   3   4   6   5   7
3 4 1   1   2   3.3 4.7 6   8
END DATA.
DATASET NAME raw.
DATASET COPY work.
DATASET ACTIVATE work.
VARSTOCASES /MAKE T FROM T1 TO T7 /INDEX=Varname(T).
COMPUTE delta=ABS(T-Time).
AGGREGATE OUTFILE * MODE=ADDVARIABLES/BREAK=SN/MinDelta=MIN(delta).
SELECT IF (delta EQ mindelta).
EXECUTE.
DELETE VARIABLES Time T delta mindelta.
CASESTOVARS ID=SN.
MATCH FILES / FILE raw / FILE * / BY SN.
EXECUTE.
DATASET CLOSE work.
LIST.
    SN     Time       T1       T2       T3       T4       T5       T6       T7 Varname.1 Varname.2
 
    1.00     2.00      .50      .60      .70     1.40     2.00     5.00     6.00 T5
    2.00     3.00     1.00     2.00     3.00     4.00     6.00     5.00     7.00 T3
    3.00     4.00     1.00     1.00     2.00     3.30     4.70     6.00     8.00 T4        T5
 
 
Number of cases read:  3    Number of cases listed:  3


nidhigupta wrote
Hi
I am a beginner in using SPSS.

I need to find
For Example in dataset below, for SN 1, i need to find the value of T1 to T7 which is closest to Value of variable 'Time'.
So for example, for row 1, the time is 2 hours, the closest time value from T1 to T7 is the time in T5, so the return value is T5


SN Time T1 T2 T3 T4 T5 T6 T7
1 2 0,5 0,6 0,7 1,4 2 5 6
2 3 1 2 3 4 6 5 7
3 4 1 1 2 3 4,7 6 8

Could you please help me write a syntax for it?
Regards
Nidhi
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?"