# Fwd: Complex logic assistance please

6 messages
Open this post in threaded view
|

## Fwd: Complex logic assistance please

 RegardsMark WebbWhatsApp +27 (72) 199 1000 [Good Reception]Cell +27 (72) 199 1000 [Poor Reception]Fax to email +27 (86) 5513075Skype  tomarkwebbEmail  [hidden email]No landline---------- Forwarded message ---------From: Mark Webb Date: Tue, 28 Jan 2020 at 13:31Subject: Complex logic assistance pleaseTo: Mark Webb <[hidden email]>Format of data is -2 Variables - Record number [can be more than 1 line per respondent], Brand usedWant to compute n_brands [how many unique brands in customer repertoire], n_shops [how many times they have shopped [I can get this via summarise - n_breaks.]Record Brand n_brands n_shops1           a           2           31           a           2           31           b           2           32           a           1           22           a           1           23           b           1           1Record 1 has 3 visits, 2 different brands bought - not loyalRecord 2 has 2 visits, 1 brand bought - loyalRecord 3 has 1 visit only - no repertoireI'm trying to compute the n_brands column i.e. the number of unique brands by record number.RegardsMark WebbWhatsApp +27 (72) 199 1000 [Good Reception]Cell +27 (72) 199 1000 [Poor Reception]Fax to email +27 (86) 5513075Skype  tomarkwebbEmail  [hidden email]No landline ===================== 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
Open this post in threaded view
|

## Re: Complex logic assistance please

 I think this is a double aggregate problem. First. Aggregate outfile=*/break=record brand/brands=nu. This gives: Record Brand brands 1           a           2 1           b           1 2           a           2 3           b           1   Second. Aggregate outfile=*/break=record/n_brands=nu This gives: Record n_brands 1            2 2            1 3            1   I think this might not be satisfying because you lose the brand variable. You can recover this by doing a match files with the second file being the table and matching by record.   Gene Maguin   From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Webb Sent: Tuesday, January 28, 2020 6:32 AM To: [hidden email] Subject: Fwd: Complex logic assistance please   Regards Mark Webb WhatsApp +27 (72) 199 1000 [Good Reception] Cell +27 (72) 199 1000 [Poor Reception] Fax to email +27 (86) 5513075 Skype  tomarkwebb Email  [hidden email] No landline   ---------- Forwarded message --------- From: Mark Webb <[hidden email]> Date: Tue, 28 Jan 2020 at 13:31 Subject: Complex logic assistance please To: Mark Webb <[hidden email]>   Format of data is - 2 Variables - Record number [can be more than 1 line per respondent], Brand used Want to compute n_brands [how many unique brands in customer repertoire], n_shops [how many times they have shopped [I can get this via summarise - n_breaks.]   Record Brand n_brands n_shops 1           a           2           3 1           a           2           3 1           b           2           3 2           a           1           2 2           a           1           2 3           b           1           1   Record 1 has 3 visits, 2 different brands bought - not loyal Record 2 has 2 visits, 1 brand bought - loyal Record 3 has 1 visit only - no repertoire   I'm trying to compute the n_brands column i.e. the number of unique brands by record number.   Regards Mark Webb WhatsApp +27 (72) 199 1000 [Good Reception] Cell +27 (72) 199 1000 [Poor Reception] Fax to email +27 (86) 5513075 Skype  tomarkwebb Email  [hidden email] No landline ===================== 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
Open this post in threaded view
|

## Re: Complex logic assistance please

 Thanks for this. I will look at and let you know if any good.In the mean time I found this - which work well.RegardsMark WebbWhatsApp +27 (72) 199 1000 [Good Reception]Cell +27 (72) 199 1000 [Poor Reception]Fax to email +27 (86) 5513075Skype  tomarkwebbEmail  [hidden email]No landlineOn Tue, 28 Jan 2020 at 16:04, Maguin, Eugene <[hidden email]> wrote: I think this is a double aggregate problem. First. Aggregate outfile=*/break=record brand/brands=nu. This gives: Record Brand brands 1           a           2 1           b           1 2           a           2 3           b           1   Second. Aggregate outfile=*/break=record/n_brands=nu This gives: Record n_brands 1            2 2            1 3            1   I think this might not be satisfying because you lose the brand variable. You can recover this by doing a match files with the second file being the table and matching by record.   Gene Maguin   From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Webb Sent: Tuesday, January 28, 2020 6:32 AM To: [hidden email] Subject: Fwd: Complex logic assistance please   Regards Mark Webb WhatsApp +27 (72) 199 1000 [Good Reception] Cell +27 (72) 199 1000 [Poor Reception] Fax to email +27 (86) 5513075 Skype  tomarkwebb Email  [hidden email] No landline   ---------- Forwarded message --------- From: Mark Webb <[hidden email]> Date: Tue, 28 Jan 2020 at 13:31 Subject: Complex logic assistance please To: Mark Webb <[hidden email]>   Format of data is - 2 Variables - Record number [can be more than 1 line per respondent], Brand used Want to compute n_brands [how many unique brands in customer repertoire], n_shops [how many times they have shopped [I can get this via summarise - n_breaks.]   Record Brand n_brands n_shops 1           a           2           3 1           a           2           3 1           b           2           3 2           a           1           2 2           a           1           2 3           b           1           1   Record 1 has 3 visits, 2 different brands bought - not loyal Record 2 has 2 visits, 1 brand bought - loyal Record 3 has 1 visit only - no repertoire   I'm trying to compute the n_brands column i.e. the number of unique brands by record number.   Regards Mark Webb WhatsApp +27 (72) 199 1000 [Good Reception] Cell +27 (72) 199 1000 [Poor Reception] Fax to email +27 (86) 5513075 Skype  tomarkwebb Email  [hidden email] No landline ===================== 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
Open this post in threaded view
|