Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72764

String and Numeric Variables- recoding

$
0
0
I have the following dataset:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float Buyer str1 Seller long Seller1
1 "D" 4
2 "B" 2
3 "C" 3
4 "A" 1
5 "B" 2
end
label values Seller1 Seller1
label def Seller1 1 "A", modify
label def Seller1 2 "B", modify
label def Seller1 3 "C", modify
label def Seller1 4 "D", modify
-------


Here, as can be seen, each observation consists of a buyer seller pair. The Buyers are labelled numerically, whereas the the variable Seller is a string variable, which I have encoded as a numeric variable as well.

Now, what I want is to make another variable for buyers (Buyer1) , that is actually a string variable, but the label for which is defined by the Seller variable. For instance, for the first observation, I want that this variable takes on the value of "A" (as that is what number 1 corresponds to as a string, defined by the seller variable) . Any help is much appreciated!

Viewing all articles
Browse latest Browse all 72764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>