Hello Team:
I have very tricky situation. The data looks as below. If respondent selects the product the data will be captured as 1 and if not it will be 0. ProductA ProductB ProductC ProductD 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 I want an output that produces the count of 1 across product combination. So based on above example, following should be the output: Combination Count ProductD 1 ProductA,B,C 1 ProductCD 1 ProductA 2 Your inputs are highly appreciated. Thanks Manmit |
Hi Manmit:
This is one of the possible ways of handling this: DATA LIST LIST/ProductA ProductB ProductC ProductD (4 F1). BEGIN DATA 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 END DATA. STRING A B C D (A1) Combined (A4). IF (ProductA=1) A='A'. IF (ProductB=1) B='B'. IF (ProductC=1) C='C'. IF (ProductD=1) D='D'. DO REPEAT Name=A B C D. - COMPUTE Combined=CONCAT(RTRIM(Combined),Name). END REPEAT. LIST. * Only the output *. FREQUENCIES VARIABLES=Combined. * As a new dataset *. AGGREGATE /OUTFILE=* /BREAK=Combined /N=N. MS> I have very tricky situation. The data looks as below. If respondent MS> selects the product the data will be captured as 1 and if not it will be MS> 0. MS> ProductA ProductB ProductC ProductD MS> 0 0 0 1 MS> 1 1 1 0 MS> 0 0 1 1 MS> 1 0 0 0 MS> 1 0 0 0 MS> I want an output that produces the count of 1 across product MS> combination. So based on above example, following should be the output: MS> Combination Count MS> ProductD 1 MS> ProductA,B,C 1 MS> ProductCD 1 MS> ProductA 2 -- Regards, Dr. Marta García-Granero,PhD mailto:[hidden email] Statistician --- "It is unwise to use a statistical procedure whose use one does not understand. SPSS syntax guide cannot supply this knowledge, and it is certainly no substitute for the basic understanding of statistics and statistical thinking that is essential for the wise choice of methods and the correct interpretation of their results". (Adapted from WinPepi manual - I'm sure Joe Abrahmson will not mind) |
In reply to this post by Manmit Shrimali-2
Hi Manmit:
Please, address your SPSS questions to the whole list, even if you are answering a message of mine... I have SPAM filters that leaves [hidden email] untouched, but that flags almost everything else as SPAM (unless the address is in a very short friends list). I spotted yours before it was deleted, but it is not always the case. MS> I appreciate your aid. Syntax works fine but concat will rise MS> 100 of variables because of the following: MS> Suppose you are on vacation and survey guy asks you which MS> number is this vacation. You will say 5. Then he will ask, when MS> you were on 4th vacation which hotels you stayed (select all that MS> apply as they can stay at multiple hotel) then when you were at MS> 3rd vacation which hotel till he gets the information till your MS> first vacation. So he will get info of current hotel stay along MS> with previous vacation and hotels stayed. MS> This is the actual problem. I think I'm missing something, because I don't understand what problem you are talking about. Make a full description of your dataset (number of variables involved, final goal...), because the syntax I wrote was fine for the tiny dataset you presented, I didn't know it was more complicated... Regards, Marta MS> DATA LIST LIST/ProductA ProductB ProductC ProductD (4 F1). MS> BEGIN DATA MS> 0 0 0 1 MS> 1 1 1 0 MS> 0 0 1 1 MS> 1 0 0 0 MS> 1 0 0 0 MS> END DATA. MS> STRING A B C D (A1) Combined (A4). MS> IF (ProductA=1) A='A'. MS> IF (ProductB=1) B='B'. MS> IF (ProductC=1) C='C'. MS> IF (ProductD=1) D='D'. MS> DO REPEAT Name=A B C D. MS> - COMPUTE Combined=CONCAT(RTRIM(Combined),Name). MS> END REPEAT. MS> LIST. MS> * Only the output *. MS> FREQUENCIES MS> VARIABLES=Combined. MS> * As a new dataset *. MS> AGGREGATE MS> /OUTFILE=* MS> /BREAK=Combined MS> /N=N. MS>> I have very tricky situation. The data looks as below. If respondent MS>> selects the product the data will be captured as 1 and if not it will be MS>> 0. MS>> ProductA ProductB ProductC ProductD MS>> 0 0 0 1 MS>> 1 1 1 0 MS>> 0 0 1 1 MS>> 1 0 0 0 MS>> 1 0 0 0 MS>> I want an output that produces the count of 1 across product MS>> combination. So based on above example, following should be the output: MS>> Combination Count MS>> ProductD 1 MS>> ProductA,B,C 1 MS>> ProductCD 1 MS>> ProductA 2 |
In reply to this post by Manmit Shrimali-2
I hope I am now addressing to correct email address. If not, please let me know on which to reply and I will.
Re: query, marta, I want to try by myself first based on the small syntax you provided. I will not be fair getting a readymade answer without trying. I wanted a hint on syntax which you gave. Hope I do succeed. Thanks Marta for sharing your sound knowledge to everyone. Manmit -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Marta García-Granero Sent: Saturday, September 30, 2006 2:36 PM To: [hidden email] Subject: Re: Frequency across the records Hi Manmit: Please, address your SPSS questions to the whole list, even if you are answering a message of mine... I have SPAM filters that leaves [hidden email] untouched, but that flags almost everything else as SPAM (unless the address is in a very short friends list). I spotted yours before it was deleted, but it is not always the case. MS> I appreciate your aid. Syntax works fine but concat will rise MS> 100 of variables because of the following: MS> Suppose you are on vacation and survey guy asks you which MS> number is this vacation. You will say 5. Then he will ask, when MS> you were on 4th vacation which hotels you stayed (select all that MS> apply as they can stay at multiple hotel) then when you were at MS> 3rd vacation which hotel till he gets the information till your MS> first vacation. So he will get info of current hotel stay along MS> with previous vacation and hotels stayed. MS> This is the actual problem. I think I'm missing something, because I don't understand what problem you are talking about. Make a full description of your dataset (number of variables involved, final goal...), because the syntax I wrote was fine for the tiny dataset you presented, I didn't know it was more complicated... Regards, Marta MS> DATA LIST LIST/ProductA ProductB ProductC ProductD (4 F1). MS> BEGIN DATA MS> 0 0 0 1 MS> 1 1 1 0 MS> 0 0 1 1 MS> 1 0 0 0 MS> 1 0 0 0 MS> END DATA. MS> STRING A B C D (A1) Combined (A4). MS> IF (ProductA=1) A='A'. MS> IF (ProductB=1) B='B'. MS> IF (ProductC=1) C='C'. MS> IF (ProductD=1) D='D'. MS> DO REPEAT Name=A B C D. MS> - COMPUTE Combined=CONCAT(RTRIM(Combined),Name). MS> END REPEAT. MS> LIST. MS> * Only the output *. MS> FREQUENCIES MS> VARIABLES=Combined. MS> * As a new dataset *. MS> AGGREGATE MS> /OUTFILE=* MS> /BREAK=Combined MS> /N=N. MS>> I have very tricky situation. The data looks as below. If respondent MS>> selects the product the data will be captured as 1 and if not it will be MS>> 0. MS>> ProductA ProductB ProductC ProductD MS>> 0 0 0 1 MS>> 1 1 1 0 MS>> 0 0 1 1 MS>> 1 0 0 0 MS>> 1 0 0 0 MS>> I want an output that produces the count of 1 across product MS>> combination. So based on above example, following should be the output: MS>> Combination Count MS>> ProductD 1 MS>> ProductA,B,C 1 MS>> ProductCD 1 MS>> ProductA 2 |
Free forum by Nabble | Edit this page |