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. |
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 |
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]]
From: Melissa Ives <[hidden email]>;
|
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. |
In reply to this post by Melissa Ives
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
|
Free forum by Nabble | Edit this page |