05-20-2014 08:52 AM
Dr. Smith has 3 addresses, I need to add a counting variable to the end of his name to indicate that all the addresses belong to him.
Dr. Smith 123 Main St
Dr. Smith 45112 East River Rd
Dr. Smith 621 Carnegie Blvd
I need to show the data as
Dr. Smith-001 123 Main St
Dr. Smith-002 45112 East River Rd
Dr. Smith-003 621 Carnegie Blvd
I don't know what this is called to be able to research how to code this.
Thanks in advance!
05-20-2014 09:01 AM
Try this, where name variable contains the dr.smith, and new_name would be with the number:
if _n_=1 or first.name then cnt=1;
05-20-2014 09:03 AM
I think the term you want is 'Slowly Changing Dimension'. Typically this would apply where one of the addresses is regarded as current while the others are previous addresses. Again, typically, there would be 'From' and 'To' dates associated with the records to show the history. The latest record would have a null 'To' date, or one far in the future such as 31DEC9999. A separate column might also be used to flag which record is the current one, to simplify queries.