I have a string variable with comma separated numbers that I want to split into four numeric variables.
| makeArr | var1a | var1b | var1c | var1d |
|---|---|---|---|---|
| 6,8,13,10 | 6 | 8 | 13 | 10 |
| 10,11,2 | 10 | 11 | 2 | |
| 7,1,14,3 | 7 | 1 | 14 | 3 |
With:
IF (CHAR.INDEX(makeArr,',') >= 1)
f12a=CHAR.SUBSTR(makeArr,1,CHAR.INDEX(makeArr,',')-1).
EXECUTE.
IF (CHAR.INDEX(makeArr,',') >= 1)
f12b=CHAR.SUBSTR(makeArr,CHAR.INDEX(makeArr,',')+1,CHAR.INDEX(makeArr,',')-1).
EXECUTE.
I always get the first variable written without any problems. This no longer works with the second variable because it has a different length and the comma is also written here.
So I would need a split at the comma and the division of the numbers over the comma.