Hello,
I have a variable po that only contains one value. However, I want to populate this variable so that if po is true for a particular id, then true will be inserted for all instances of that id, otherwise the value false will be inserted. In the example below, true would be inserted for id 31278 and then all other values would be false. Is a loop required to do this or is there an easier option.
I then plan to identify duplicates and retain the row with the earliest value for the variable dateordermade . In the case of 31278 this would mean retaining the second instance and for id 444235 the first instance (of 3). Date is an int variable, I believe I need to generate a new date variable using mdy. Is a loop then required to remove the later duplicates.
Any assistance is required.
Bob
I have a variable po that only contains one value. However, I want to populate this variable so that if po is true for a particular id, then true will be inserted for all instances of that id, otherwise the value false will be inserted. In the example below, true would be inserted for id 31278 and then all other values would be false. Is a loop required to do this or is there an easier option.
I then plan to identify duplicates and retain the row with the earliest value for the variable dateordermade . In the case of 31278 this would mean retaining the second instance and for id 444235 the first instance (of 3). Date is an int variable, I believe I need to generate a new date variable using mdy. Is a loop then required to remove the later duplicates.
Any assistance is required.
Bob
:
version 14 cd "D:\" set type double set more off clear db import excel * "D:\Test1.xls" list encode status, gen (status2) drop if status2 == 1
:
id surname firstfame dateordermade status po status2 31278 Jones Daniel 14dec2004 Open True Open 31278 Jones Daniel 04may2000 Open Open 35022 Brown Joan 06sep2002 Open Open 378444 White Bill 30apr2014 Open Open 444235 White Zac 18mar2006 Open Open 444235 White Zac 08feb2014 Open Open 444235 White Zac 08feb2012 Open Open