Add cases in spss data of the multi-case format

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

Add cases in spss data of the multi-case format

Binh
Hello,
I’d need your help. My current spss data is in multi-case format as follows – 2 respondents, each of them answers the question “favorite” for 2 brands coded 1,2 in the question “brand”.
id brand favorite
1 1 3
1 2 2
2 1 1
2 2 5

I’d like to insert a brand (coded 3) for each of respondent and impute data of the question “favorite” for this brand at respondent level as follows.
id brand favorite
1 1 3
1 2 2
1 3 =average(brand 1,brand 2)
2 1 1
2 2 5
2 3 =average(brand 1, brand 2)

I am wondering if there is any syntax which helps me to do the above task directly without restructuring data. Could you please advise. Many thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Add cases in spss data of the multi-case format

Melissa Ives
You could use AGGREGATE to create a file with the 3rd row, then use ADD FILES to combine the original and the aggregated file, the sort by id and brand (unless you used  a by statement in ADD FILES).
Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Binh
Sent: Sunday, January 27, 2013 9:28 AM
To: [hidden email]
Subject: [SPSSX-L] Add cases in spss data of the multi-case format

Hello,
I’d need your help. My current spss data is in multi-case format as follows – 2 respondents, each of them answers the question “favorite” for 2 brands coded 1,2 in the question “brand”.
id      brand   favorite
1       1       3
1       2       2
2       1       1
2       2       5

I’d like to insert a brand (coded 3) for each of respondent and impute data of the question “favorite” for this brand at respondent level as follows.
id      brand   favorite
1       1       3
1       2       2
1       3       =average(brand 1,brand 2)
2       1       1
2       2       5
2       3       =average(brand 1, brand 2)

I am wondering if there is any syntax which helps me to do the above task directly without restructuring data. Could you please advise. Many thanks.




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Add-cases-in-spss-data-of-the-multi-case-format-tp5717736.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

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

=====================
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: Add cases in spss data of the multi-case format

Melissa Ives
In reply to this post by Binh

If you truly want to keep the average of the first favorites in the same variable, and calculate the Brand as one higher than the ‘last brand’ for the ID, then this will do the trick.. tested on one with 3 brands.

Of course you will need to edit the file path/names below (red bold).

 

Sort cases by id brand.

AGGREGATE outfile='P:\favbrand.sav'

   /break=ID/favorite=mean(favorite).

 

Add files file=*/file='P:\favbrand.sav'/by ID.

if missing(brand) brand=lag(brand)+1.

exe.

 

ID            Brand    favorite

1.00        1.00        3.00

1.00        2.00        2.00

1.00        3.00        2.50 ßinserted row with above syntax

2.00        1.00        1.00

2.00        2.00        5.00

2.00        3.00        3.00 ßinserted row with above syntax

3.00        1.00        4.00

3.00        2.00        2.00

3.00        3.00        1.00

3.00        4.00        2.33 ßinserted row with above syntax

 

From: Binh Nguyen [mailto:[hidden email]]
Sent: Saturday, February 02, 2013 8:02 PM
To: Melissa Ives
Subject: Re: [SPSSX-L] Add cases in spss data of the multi-case format

 

Hi Melissa,

Thank you for your advice. Can I interpret your advice that I can use a similar way (aggregate) to impute data of the variable "favorite" for the newly added cases?

ManyThanks,

Binh

 


From: Melissa Ives <[hidden email]>;
To: Binh <[hidden email]>; [hidden email] <[hidden email]>;
Subject: RE: [SPSSX-L] Add cases in spss data of the multi-case format
Sent: Mon, Jan 28, 2013 4:43:34 PM

You could use AGGREGATE to create a file with the 3rd row, then use ADD FILES to combine the original and the aggregated file, the sort by id and brand (unless you used  a by statement in ADD FILES).
Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:<a href="javascript:return">SPSSX-L@...] On Behalf Of Binh
Sent: Sunday, January 27, 2013 9:28 AM
To: <a href="javascript:return">SPSSX-L@...
Subject: [SPSSX-L] Add cases in spss data of the multi-case format

Hello,
I’d need your help. My current spss data is in multi-case format as follows – 2 respondents, each of them answers the question “favorite” for 2 brands coded 1,2 in the question “brand”.
id      brand  favorite
1      1      3
1      2      2
2      1      1
2      2      5

I’d like to insert a brand (coded 3) for each of respondent and impute data of the question “favorite” for this brand at respondent level as follows.
id      brand  favorite
1      1      3
1      2      2
1      3      =average(brand 1,brand 2)
2      1      1
2      2      5
2      3      =average(brand 1, brand 2)

I am wondering if there is any syntax which helps me to do the above task directly without restructuring data. Could you please advise. Many thanks.




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Add-cases-in-spss-data-of-the-multi-case-format-tp5717736.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to <a href="javascript:return">LISTSERV@... (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

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

 

Reply | Threaded
Open this post in threaded view
|

Automatic reply: Add cases in spss data of the multi-case format

Susan Maree Cotton

It is a lovely time of the year when NHMRC grant submissions are due.   Priority is currently being given to these grants.  If your email is not grant related, then it may take some to time for me to respond.

Reply | Threaded
Open this post in threaded view
|

Re: Add cases in spss data of the multi-case format

Binh
In reply to this post by Melissa Ives
Hi Mellisa,

Many Thanks for your thoughtfull explanation.

Binh


From: Melissa Ives [via SPSSX Discussion] <[hidden email]>;
To: Binh <[hidden email]>;
Subject: Re: Add cases in spss data of the multi-case format
Sent: Mon, Feb 4, 2013 2:53:07 PM

If you truly want to keep the average of the first favorites in the same variable, and calculate the Brand as one higher than the ‘last brand’ for the ID, then this will do the trick.. tested on one with 3 brands.

Of course you will need to edit the file path/names below (red bold).

 

Sort cases by id brand.

AGGREGATE outfile='P:\favbrand.sav'

   /break=ID/favorite=mean(favorite).

 

Add files file=*/file='P:\favbrand.sav'/by ID.

if missing(brand) brand=lag(brand)+1.

exe.

 

ID            Brand    favorite

1.00        1.00        3.00

1.00        2.00        2.00

1.00        3.00        2.50 ßinserted row with above syntax

2.00        1.00        1.00

2.00        2.00        5.00

2.00        3.00        3.00 ßinserted row with above syntax

3.00        1.00        4.00

3.00        2.00        2.00

3.00        3.00        1.00

3.00        4.00        2.33 ßinserted row with above syntax

 

From: Binh Nguyen [mailto:[hidden email]]
Sent: Saturday, February 02, 2013 8:02 PM
To: Melissa Ives
Subject: Re: [SPSSX-L] Add cases in spss data of the multi-case format

 

Hi Melissa,

Thank you for your advice. Can I interpret your advice that I can use a similar way (aggregate) to impute data of the variable "favorite" for the newly added cases?

ManyThanks,

Binh

 


From: Melissa Ives <[hidden email]>;
To: Binh <[hidden email]>; [hidden email] <[hidden email]>;
Subject: RE: [SPSSX-L] Add cases in spss data of the multi-case format
Sent: Mon, Jan 28, 2013 4:43:34 PM

You could use AGGREGATE to create a file with the 3rd row, then use ADD FILES to combine the original and the aggregated file, the sort by id and brand (unless you used  a by statement in ADD FILES).
Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:<a href="javascript:return">SPSSX-L@...] On Behalf Of Binh
Sent: Sunday, January 27, 2013 9:28 AM
To: <a href="javascript:return">SPSSX-L@...
Subject: [SPSSX-L] Add cases in spss data of the multi-case format

Hello,
I’d need your help. My current spss data is in multi-case format as follows – 2 respondents, each of them answers the question “favorite” for 2 brands coded 1,2 in the question “brand”.
id      brand  favorite
1      1      3
1      2      2
2      1      1
2      2      5

I’d like to insert a brand (coded 3) for each of respondent and impute data of the question “favorite” for this brand at respondent level as follows.
id      brand  favorite
1      1      3
1      2      2
1      3      =average(brand 1,brand 2)
2      1      1
2      2      5
2      3      =average(brand 1, brand 2)

I am wondering if there is any syntax which helps me to do the above task directly without restructuring data. Could you please advise. Many thanks.




--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Add-cases-in-spss-data-of-the-multi-case-format-tp5717736.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to <a href="javascript:return">LISTSERV@... (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

PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.

 




If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/Add-cases-in-spss-data-of-the-multi-case-format-tp5717736p5717897.html
To unsubscribe from Add cases in spss data of the multi-case format, click here.
NAML