I have a string variable that needs a digit added.
The first six values shown below are what this variable "should" look like, but for some reason, about 200 records that should end with a "1" had the 1 removed.
I have attempted this:
and this (assuming maybe that the "1" was replaced with an extra space " " at the end? Should I use trim?):
and this:
And neither seemed to work. Can someone kindly explain this to me like I'm a little kid? Crazymaking, lol.
Here's a listing of the variable. The first six records are the correct format, the remaining records are a subset of those missing the final "1"
The first six values shown below are what this variable "should" look like, but for some reason, about 200 records that should end with a "1" had the 1 removed.
I have attempted this:
Code:
replace aparticipant_id = subinstr(aparticipant_id, "*-0", "*-01", 1)
Code:
replace aparticipant_id = subinstr(aparticipant_id, "*-0 ", "*-01", 1)
Code:
gen tempx = subinstr(aparticipant_id, "*-0 ", "*-01", 1) replace aparticipant_id = tempx if aparticipant_id != tempx
Here's a listing of the variable. The first six records are the correct format, the remaining records are a subset of those missing the final "1"
Code:
aparticipant_id SLE-KEN-GOU-001-01 SLE-KEN-GOU-001-02 SLE-KEN-GOU-002-01 SLE-KEN-GOU-002-02 SLE-KEN-GOU-002-03 SLE-KEN-GOU-002-04 SLE-KEN-HAN-001-0 SLE-KEN-HAN-002-0 SLE-KEN-HAN-003-0 SLE-KEN-HAN-004-0 SLE-KEN-HAN-005-0 SLE-KEN-HAN-006-0 SLE-KEN-KOI-001-0 SLE-KEN-KOI-002-0 SLE-KEN-KOI-003-0 SLE-KEN-KOI-004-0 SLE-KEN-KOI-005-0 SLE-KEN-KOI-006-0 SLE-KEN-KOI-007-0 SLE-KEN-KOI-008-0 SLE-KEN-KOI-009-0 SLE-KEN-KOI-010-0 SLE-KEN-KOI-011-0 SLE-KEN-KOI-012-0 SLE-KEN-KOI-013-0 SLE-KEN-KOI-014-0 SLE-KEN-KOI-015-0 SLE-KEN-KOI-016-0 SLE-KEN-KOI-017-0 SLE-KEN-KOL-001-0 SLE-KEN-KOL-002-0 SLE-KEN-KOL-003-0 SLE-KEN-KOL-004-0 SLE-KEN-KOL-005-0 SLE-KEN-KOL-006-0 SLE-KEN-KOL-007-0 SLE-KEN-KOL-008-0 SLE-KEN-KOL-009-0 SLE-KEN-KOL-010-0 SLE-KEN-KOL-011-0 SLE-KEN-KOL-012-0 SLE-KEN-KOL-013-0 SLE-KEN-KOL-014-0 SLE-KEN-KOL-015-0 SLE-KEN-KOL-016-0 SLE-KEN-KOL-017-0 SLE-KEN-KOL-018-0 SLE-KEN-KOL-019-0 SLE-KEN-KOL-020-0

Comment