Hello, I have a question as to how to generate a variable based on some conditions, I have these relevant variables (CASENUM PHONETYPE PHONENUMBER). I want to generate a new variable that consists of the duplicate cell numbers, so in the example below, there are 4 duplicates, I want to maintain the second, I want this for all cases where there are duplicate CASENUMBERS and cell phones. I hope this question makes sense
* Example generated by -dataex-. For more info, type help dataex
clear
input str12 CASENUM str16 PHONETYPE double PHONENUMBER
"SAPD24118937" "Cell" 18304316624
"SAPD24118889" "Cell" 12109791643
"SAPD24118835" "Cell" 14024994996
"SAPD24118777" "Cell" 12812544320
"SAPD24118755" "Cell" 17856141487
"SAPD24118755" "Cell" 13038701951
"SAPD24118519" "Cell" 12106053538
"SAPD24118322" "Cell" 12106438156
"SAPD24118198" "Cell" 12252784565
"SAPD24118113" "Cell" 13613433082
"SAPD24117355" "Cell" 12109622257
"SAPD24117332" "Cell" 12107711890
"SAPD24117332" "Home" 17547799
"SAPD24117332" "Home" 12104452311
"SAPD24117313" "Cell" 15095928290
"SAPD24117309" "Cell" 12103866666
"SAPD24117285" "Cell" 12107710816
"SAPD24117283" "Home" 16263285
"SAPD24117283" "Cell" 12104541543
"SAPD24117155" "Cell" 12108105758
"SAPD24116684" "Cell" 12105178751
"SAPD24116652" "Cell" 15614258338
"SAPD24116633" "Cell" 12107179800
"SAPD24116617" "Cell" 12547072120
"SAPD24116556" "Cell" 17262067496
"SAPD24116238" "Work" 12106890915
"SAPD24116238" "Cell" 12107168732
"SAPD24116238" "Other" 12105733008
"SAPD24115375" "Cell" 12102871475
"SAPD24115319" "Other" 12104265972
"SAPD24115279" "" .
"SAPD24115279" "Cell" 18325854444
"SAPD24115247" "Cell" 12108484932
"SAPD24114875" "Cell" 18305818695
"SAPD24114836" "Work" 12103662304
"SAPD24114836" "Home" 14796002
"SAPD24114836" "Other" 12102136075
"SAPD24114836" "Other" 12102136975
"SAPD24114824" "Home" 12102871383
"SAPD24114824" "Cell" 13614459044
"SAPD24114824" "Other" 18303050607
"SAPD24114770" "Other" 12103855645
"SAPD24114759" "Cell" 18306942226
"SAPD24114692" "Cell" 12145639030
"SAPD24114658" "Work" 12102062238
"SAPD24114658" "Cell" 12103780789
"SAPD24114544" "Cell" 17263339822
"SAPD24114451" "Cell" 12106300710
"SAPD24114368" "Cell" 14328160330
"SAPD24114342" "Other" 12109877906
"SAPD24114271" "Cell" 12103859859
"SAPD24114255" "Cell" 12102515863
"SAPD24114025" "Cell" 19542257783
"SAPD24113868" "Cell" 13526344163
"SAPD24113859" "Cell" 19404358533
"SAPD24113829" "Work" 12104106553
"SAPD24113829" "Other" 18305708881
"SAPD24113799" "Cell" 14328894618
"SAPD24113799" "Cell" 14328892030
"SAPD24113740" "Cell" 14328038084
"SAPD24113630" "Cell" 17872426437
"SAPD24113458" "Cell" 16083439978
"SAPD24113439" "Cell" 12102547088
"SAPD24113428" "Cell" 18315962388
"SAPD24113306" "Cell" 12104730533
"SAPD24113212" "Cell" 12102907162
"SAPD24113212" "Cell" 12102942307
"SAPD24113193" "Cell" 19034531168
"SAPD24113108" "Cell" 17262094027
"SAPD24111630" "Cell" 17267770236
"SAPD24111630" "Cell" 12107945931
"SAPD24111630" "Work" 12105341874
"SAPD24111630" "Other" 12104655628
"SAPD24111551" "Cell" 12108129810
"SAPD24111487" "Cell" 15596946571
"SAPD24111414" "Cell" 18303189541
"SAPD24111414" "Other" 12107794694
"SAPD24111379" "Cell" 12103653666
"SAPD24110966" "Cell" 18325840971
"SAPD24110660" "Cell" 12108595319
"SAPD24110498" "Cell" 12105890399
"SAPD24110011" "Cell" 12103320671
"SAPD24109950" "Cell" 12104390646
"SAPD24109941" "Cell" 17209660481
"SAPD24109786" "Cell" 18329357982
"SAPD24109677" "Cell" 12108834344
"SAPD24108872" "" .
"SAPD24108807" "Cell" 18305131205
"SAPD24108746" "Cell" 12106680556
"SAPD24108727" "Cell" 19562363062
"SAPD24108472" "Home" 19033609332
"SAPD24108472" "Cell" 12103800924
"SAPD24108472" "Cell" 12107276540
"SAPD24108372" "Cell" 12105961760
"SAPD24108372" "Cell" 12106678965
"SAPD24108326" "Cell" 19794804347
"SAPD24108235" "" .
"SAPD24108235" "Cell" 12108127268
"SAPD24108217" "Cell" 18169165169
"SAPD24107440" "Cell" 14694505791
end
[/CODE]
------------------ copy up to and including the previous line ----------------
SAPD24111630 | Cell |
SAPD24111630 | Cell |
SAPD24111630 | Cell |
SAPD24111630 | Work |
SAPD24111630 | Other |
* Example generated by -dataex-. For more info, type help dataex
clear
input str12 CASENUM str16 PHONETYPE double PHONENUMBER
"SAPD24118937" "Cell" 18304316624
"SAPD24118889" "Cell" 12109791643
"SAPD24118835" "Cell" 14024994996
"SAPD24118777" "Cell" 12812544320
"SAPD24118755" "Cell" 17856141487
"SAPD24118755" "Cell" 13038701951
"SAPD24118519" "Cell" 12106053538
"SAPD24118322" "Cell" 12106438156
"SAPD24118198" "Cell" 12252784565
"SAPD24118113" "Cell" 13613433082
"SAPD24117355" "Cell" 12109622257
"SAPD24117332" "Cell" 12107711890
"SAPD24117332" "Home" 17547799
"SAPD24117332" "Home" 12104452311
"SAPD24117313" "Cell" 15095928290
"SAPD24117309" "Cell" 12103866666
"SAPD24117285" "Cell" 12107710816
"SAPD24117283" "Home" 16263285
"SAPD24117283" "Cell" 12104541543
"SAPD24117155" "Cell" 12108105758
"SAPD24116684" "Cell" 12105178751
"SAPD24116652" "Cell" 15614258338
"SAPD24116633" "Cell" 12107179800
"SAPD24116617" "Cell" 12547072120
"SAPD24116556" "Cell" 17262067496
"SAPD24116238" "Work" 12106890915
"SAPD24116238" "Cell" 12107168732
"SAPD24116238" "Other" 12105733008
"SAPD24115375" "Cell" 12102871475
"SAPD24115319" "Other" 12104265972
"SAPD24115279" "" .
"SAPD24115279" "Cell" 18325854444
"SAPD24115247" "Cell" 12108484932
"SAPD24114875" "Cell" 18305818695
"SAPD24114836" "Work" 12103662304
"SAPD24114836" "Home" 14796002
"SAPD24114836" "Other" 12102136075
"SAPD24114836" "Other" 12102136975
"SAPD24114824" "Home" 12102871383
"SAPD24114824" "Cell" 13614459044
"SAPD24114824" "Other" 18303050607
"SAPD24114770" "Other" 12103855645
"SAPD24114759" "Cell" 18306942226
"SAPD24114692" "Cell" 12145639030
"SAPD24114658" "Work" 12102062238
"SAPD24114658" "Cell" 12103780789
"SAPD24114544" "Cell" 17263339822
"SAPD24114451" "Cell" 12106300710
"SAPD24114368" "Cell" 14328160330
"SAPD24114342" "Other" 12109877906
"SAPD24114271" "Cell" 12103859859
"SAPD24114255" "Cell" 12102515863
"SAPD24114025" "Cell" 19542257783
"SAPD24113868" "Cell" 13526344163
"SAPD24113859" "Cell" 19404358533
"SAPD24113829" "Work" 12104106553
"SAPD24113829" "Other" 18305708881
"SAPD24113799" "Cell" 14328894618
"SAPD24113799" "Cell" 14328892030
"SAPD24113740" "Cell" 14328038084
"SAPD24113630" "Cell" 17872426437
"SAPD24113458" "Cell" 16083439978
"SAPD24113439" "Cell" 12102547088
"SAPD24113428" "Cell" 18315962388
"SAPD24113306" "Cell" 12104730533
"SAPD24113212" "Cell" 12102907162
"SAPD24113212" "Cell" 12102942307
"SAPD24113193" "Cell" 19034531168
"SAPD24113108" "Cell" 17262094027
"SAPD24111630" "Cell" 17267770236
"SAPD24111630" "Cell" 12107945931
"SAPD24111630" "Work" 12105341874
"SAPD24111630" "Other" 12104655628
"SAPD24111551" "Cell" 12108129810
"SAPD24111487" "Cell" 15596946571
"SAPD24111414" "Cell" 18303189541
"SAPD24111414" "Other" 12107794694
"SAPD24111379" "Cell" 12103653666
"SAPD24110966" "Cell" 18325840971
"SAPD24110660" "Cell" 12108595319
"SAPD24110498" "Cell" 12105890399
"SAPD24110011" "Cell" 12103320671
"SAPD24109950" "Cell" 12104390646
"SAPD24109941" "Cell" 17209660481
"SAPD24109786" "Cell" 18329357982
"SAPD24109677" "Cell" 12108834344
"SAPD24108872" "" .
"SAPD24108807" "Cell" 18305131205
"SAPD24108746" "Cell" 12106680556
"SAPD24108727" "Cell" 19562363062
"SAPD24108472" "Home" 19033609332
"SAPD24108472" "Cell" 12103800924
"SAPD24108472" "Cell" 12107276540
"SAPD24108372" "Cell" 12105961760
"SAPD24108372" "Cell" 12106678965
"SAPD24108326" "Cell" 19794804347
"SAPD24108235" "" .
"SAPD24108235" "Cell" 12108127268
"SAPD24108217" "Cell" 18169165169
"SAPD24107440" "Cell" 14694505791
end
[/CODE]
------------------ copy up to and including the previous line ----------------
Comment