Hi everyone,
I would like to do a simple operation. Basically, I want to substract one string from a variable, and include it in another one.
Here is a dataex for more clarity:
Basically, for all string values in variable "CO2gkm" following this pattern: "xxx x", I want to take the last "x" and add it to the "cv" values, at the beginning of the string.
So, for example in my data example, in the first line, I would like to extract the last "1" from CO2gkm, and add it to the beginning of "70" in cv, to have "170", and so on for other variables.
Could anyone give me some insights about that, please?
Thank you in advance!
Best,
Michael
I would like to do a simple operation. Basically, I want to substract one string from a variable, and include it in another one.
Here is a dataex for more clarity:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str5(CO2gkm cv) "148 1" "70" "153 1" "70" "155 1" "35" "150 1" "40" "155 1" "60" "150 1" "60" "155 1" "60" "150 1" "60" "139 1" "80" "134 1" "80" end
Basically, for all string values in variable "CO2gkm" following this pattern: "xxx x", I want to take the last "x" and add it to the "cv" values, at the beginning of the string.
So, for example in my data example, in the first line, I would like to extract the last "1" from CO2gkm, and add it to the beginning of "70" in cv, to have "170", and so on for other variables.
Could anyone give me some insights about that, please?
Thank you in advance!
Best,
Michael
Comment