Dear all,
I have a dataset including two string variables, str1 and str2. Both display various pairs of numbers, in the style "A:B , A:B , ..." Suppose that for a given observation (row), str1 equals
"15000:4500 , 17540:5000 , 16000:1000"
(The "" are not part of the string, I just use them here for clarification; however, the comma inbetween pairs is part of the string)
and str2 equals
"15000:2000 , 19000:2000 , 16000:900 , 16490:400".
I would like to create a dummy variable wich takes 1 (and 0 otherwise) if:
a) There is at least one pair in str1 and str2 that share the same A
AND
b) for at least one such case (i.e. common A), the associated B in str1 is larger than the associated B in str2.
In my above example, a) is satisfied because there are two cases of common A (where these A's are 15000 and 16000), and b) is satisfied because looking at the pairs with A=15000, we see that 4500 is larger than 2000. Therefore, the to-be-created dummy variable should take 1.
I have thought about this for a while and searched the Internet but could not find a hint or answer. I hope someone can help me out!
I have a dataset including two string variables, str1 and str2. Both display various pairs of numbers, in the style "A:B , A:B , ..." Suppose that for a given observation (row), str1 equals
"15000:4500 , 17540:5000 , 16000:1000"
(The "" are not part of the string, I just use them here for clarification; however, the comma inbetween pairs is part of the string)
and str2 equals
"15000:2000 , 19000:2000 , 16000:900 , 16490:400".
I would like to create a dummy variable wich takes 1 (and 0 otherwise) if:
a) There is at least one pair in str1 and str2 that share the same A
AND
b) for at least one such case (i.e. common A), the associated B in str1 is larger than the associated B in str2.
In my above example, a) is satisfied because there are two cases of common A (where these A's are 15000 and 16000), and b) is satisfied because looking at the pairs with A=15000, we see that 4500 is larger than 2000. Therefore, the to-be-created dummy variable should take 1.
I have thought about this for a while and searched the Internet but could not find a hint or answer. I hope someone can help me out!
Comment