matching single with multiple ids

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

matching single with multiple ids

Zdaniuk, Bozena-2
Hello, i have one file with multiple rows for the same id, and i want to merge in a variable from another file which has only one value for each id (one row). I would like the variable value to be repeated for each row with the same id (see below). When i try the regular merging, i get the value put in only for the first instance of the id and empty cell for the rest of the same id. Can someone help? thanks a lot.

I have one file with:
id
1
1
1
2
2
2

and another file with:
id      var1
1       4
2       3

i want to end up with a file with:
id     var1
1      4
1      4
1      4
2      3
2      3
2     3

________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Harrington, Donna [[hidden email]]
Sent: Friday, March 07, 2008 1:46 PM
To: [hidden email]
Subject: Re: Extracting Time, Time Zone from a String Variable

Hi Richard,

Thanks for putting me on a path towards resolving my problem.  I am having trouble, though, reproducing your output.  I will post in segments, if that is ok, as I want to be really clear in my learning.  For I a-c:

I understand all of the commands except:
>  NUMERIC Time12   (TIME6).  Why (Time6)?
>  NUMERIC #Index (F4).   Why (F4)?

Then, this is the output on my way to the same table you posted.
How should I understand the warnings?

Thanks,

Donna


NUMERIC Time12   (TIME6).
STRING   (AM.PM) (A3).

>Error # 4293 in column 10.  Text: (
>The variable list is empty.
>This command not executed.


>Error # 4361 in column 11.  Text: AM.PM
>The format contains a misplaced period.

STRING  Zone (A5).

STRING #Parsing (A30).
NUMERIC #Index (F4).

COMPUTE #Parsing = LTRIM (Contact_Time).

COMPUTE #Index = INDEX (#Parsing, ' ' ).
COMPUTE Time12 = NUMBER (SUBSTR(#Parsing,1,#Index), TIME6).

COMPUTE #Parsing = LTRIM (SUBSTR(#Parsing, #Index)).

COMPUTE #Index = INDEX (#Parsing, ' ').
COMPUTE AM.PM = SUBSTR(#Parsing,1,#Index).

>Error # 4309 in column 256.  Text: (End of Command)
>Invalid combination of data types in an assignment.  Character strings may
>only be assigned to string variables.  Numeric and logical quantities may
>only be assigned to numeric variables.  Consider using the STRING or NUMBER
>function.
>This command not executed.


COMPUTE #Parsing = LTRIM (SUBSTR(#Parsing,#Index)).

COMPUTE Zone = #Parsing.
LIST.

**************OUTPUT CREATED*************
*****************************************
contact_time Time12 Zone

2:52 pm PT     2:52 PT
3:35 pm PT     3:35 PT
3:37 pm PT     3:37 PT
1:35 pm PT     1:35 PT
3:39 pm PT     3:39 PT
3:41 pm PT     3:41 PT
3:43 pm PT     3:43 PT
6:35 pm CT     6:35 CT
1:13 pm CT     1:13 CT
1:41 pm CT     1:41 CT


Number of cases read:  10    Number of cases listed:  10

=====================
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: matching single with multiple ids

Maguin, Eugene
Bozena,

Look at the table subcommand to the match files command.

Gene Maguin

=====================
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: matching single with multiple ids

Wilhelm Svensson | Queue Sweden AB
In reply to this post by Zdaniuk, Bozena-2
Hi,

This syntax will do the trick. (SPSS 15)

AGGREGATE
  /OUTFILE=*
  MODE=ADDVARIABLES
  /BREAK=id
  /N=N.

All the best

Wilhelm Svensson | +46-735-460000 | [hidden email]
Queue Sweden AB - A Management Science Company | www.qsweden.com

-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För Zdaniuk,
Bozena
Skickat: den 7 mars 2008 20:07
Till: [hidden email]
Ämne: matching single with multiple ids

Hello, i have one file with multiple rows for the same id, and i want to
merge in a variable from another file which has only one value for each id
(one row). I would like the variable value to be repeated for each row with
the same id (see below). When i try the regular merging, i get the value put
in only for the first instance of the id and empty cell for the rest of the
same id. Can someone help? thanks a lot.

I have one file with:
id
1
1
1
2
2
2

and another file with:
id      var1
1       4
2       3

i want to end up with a file with:
id     var1
1      4
1      4
1      4
2      3
2      3
2     3

________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of
Harrington, Donna [[hidden email]]
Sent: Friday, March 07, 2008 1:46 PM
To: [hidden email]
Subject: Re: Extracting Time, Time Zone from a String Variable

Hi Richard,

Thanks for putting me on a path towards resolving my problem.  I am having
trouble, though, reproducing your output.  I will post in segments, if that
is ok, as I want to be really clear in my learning.  For I a-c:

I understand all of the commands except:
>  NUMERIC Time12   (TIME6).  Why (Time6)?
>  NUMERIC #Index (F4).   Why (F4)?

Then, this is the output on my way to the same table you posted.
How should I understand the warnings?

Thanks,

Donna


NUMERIC Time12   (TIME6).
STRING   (AM.PM) (A3).

>Error # 4293 in column 10.  Text: (
>The variable list is empty.
>This command not executed.


>Error # 4361 in column 11.  Text: AM.PM
>The format contains a misplaced period.

STRING  Zone (A5).

STRING #Parsing (A30).
NUMERIC #Index (F4).

COMPUTE #Parsing = LTRIM (Contact_Time).

COMPUTE #Index = INDEX (#Parsing, ' ' ).
COMPUTE Time12 = NUMBER (SUBSTR(#Parsing,1,#Index), TIME6).

COMPUTE #Parsing = LTRIM (SUBSTR(#Parsing, #Index)).

COMPUTE #Index = INDEX (#Parsing, ' ').
COMPUTE AM.PM = SUBSTR(#Parsing,1,#Index).

>Error # 4309 in column 256.  Text: (End of Command)
>Invalid combination of data types in an assignment.  Character strings may
>only be assigned to string variables.  Numeric and logical quantities may
>only be assigned to numeric variables.  Consider using the STRING or NUMBER
>function.
>This command not executed.


COMPUTE #Parsing = LTRIM (SUBSTR(#Parsing,#Index)).

COMPUTE Zone = #Parsing.
LIST.

**************OUTPUT CREATED*************
*****************************************
contact_time Time12 Zone

2:52 pm PT     2:52 PT
3:35 pm PT     3:35 PT
3:37 pm PT     3:37 PT
1:35 pm PT     1:35 PT
3:39 pm PT     3:39 PT
3:41 pm PT     3:41 PT
3:43 pm PT     3:43 PT
6:35 pm CT     6:35 CT
1:13 pm CT     1:13 CT
1:41 pm CT     1:41 CT


Number of cases read:  10    Number of cases listed:  10

=====================
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

=====================
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
|

SV: matching single with multiple ids

Wilhelm Svensson | Queue Sweden AB
In reply to this post by Zdaniuk, Bozena-2
Hi aging,

Sorry didn't read your problem all why thru.

You looking for:

*Open the both files, activate the file you want your result to be added.
Run the following SYNTAX.

MATCH FILES
  /FILE=*
  /TABLE='DataSet1' /* The name of the table there var1 is located */
  /BY id.
EXECUTE.

Don't forget to sort your both files by id. !!!

SORT CASES BY
  id (A) .
Execute.

Sorry for my last answer, I thought it was another type of problem.

All the best

Wilhelm Svensson | +46-735-460000 | [hidden email]
Queue Sweden AB - A Management Science Company | www.qsweden.com

-----Ursprungligt meddelande-----
Från: SPSSX(r) Discussion [mailto:[hidden email]] För Zdaniuk,
Bozena
Skickat: den 7 mars 2008 20:07
Till: [hidden email]
Ämne: matching single with multiple ids

Hello, i have one file with multiple rows for the same id, and i want to
merge in a variable from another file which has only one value for each id
(one row). I would like the variable value to be repeated for each row with
the same id (see below). When i try the regular merging, i get the value put
in only for the first instance of the id and empty cell for the rest of the
same id. Can someone help? thanks a lot.

I have one file with:
id
1
1
1
2
2
2

and another file with:
id      var1
1       4
2       3

i want to end up with a file with:
id     var1
1      4
1      4
1      4
2      3
2      3
2     3

________________________________________
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of
Harrington, Donna [[hidden email]]
Sent: Friday, March 07, 2008 1:46 PM
To: [hidden email]
Subject: Re: Extracting Time, Time Zone from a String Variable

Hi Richard,

Thanks for putting me on a path towards resolving my problem.  I am having
trouble, though, reproducing your output.  I will post in segments, if that
is ok, as I want to be really clear in my learning.  For I a-c:

I understand all of the commands except:
>  NUMERIC Time12   (TIME6).  Why (Time6)?
>  NUMERIC #Index (F4).   Why (F4)?

Then, this is the output on my way to the same table you posted.
How should I understand the warnings?

Thanks,

Donna


NUMERIC Time12   (TIME6).
STRING   (AM.PM) (A3).

>Error # 4293 in column 10.  Text: (
>The variable list is empty.
>This command not executed.


>Error # 4361 in column 11.  Text: AM.PM
>The format contains a misplaced period.

STRING  Zone (A5).

STRING #Parsing (A30).
NUMERIC #Index (F4).

COMPUTE #Parsing = LTRIM (Contact_Time).

COMPUTE #Index = INDEX (#Parsing, ' ' ).
COMPUTE Time12 = NUMBER (SUBSTR(#Parsing,1,#Index), TIME6).

COMPUTE #Parsing = LTRIM (SUBSTR(#Parsing, #Index)).

COMPUTE #Index = INDEX (#Parsing, ' ').
COMPUTE AM.PM = SUBSTR(#Parsing,1,#Index).

>Error # 4309 in column 256.  Text: (End of Command)
>Invalid combination of data types in an assignment.  Character strings may
>only be assigned to string variables.  Numeric and logical quantities may
>only be assigned to numeric variables.  Consider using the STRING or NUMBER
>function.
>This command not executed.


COMPUTE #Parsing = LTRIM (SUBSTR(#Parsing,#Index)).

COMPUTE Zone = #Parsing.
LIST.

**************OUTPUT CREATED*************
*****************************************
contact_time Time12 Zone

2:52 pm PT     2:52 PT
3:35 pm PT     3:35 PT
3:37 pm PT     3:37 PT
1:35 pm PT     1:35 PT
3:39 pm PT     3:39 PT
3:41 pm PT     3:41 PT
3:43 pm PT     3:43 PT
6:35 pm CT     6:35 CT
1:13 pm CT     1:13 CT
1:41 pm CT     1:41 CT


Number of cases read:  10    Number of cases listed:  10

=====================
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

=====================
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