I have a simple problem. I have the letters of the alphabet ordered differently after 2 different lists (order_pre and order_post). Now I would like to create an artificial word that contains the letters in the order given by the order of each order variable as a single string. I.e. I would like to create a local macro or variable called word_pre for order_pre that reads "abc" and the same for order_post reading "bac.
Code:
clear input order_pre str1 letters order_post 1 "a" 2 2 "b" 1 3 "c" 3 end * word_pre should be "abc" preserve sort order_pre levelsof letters, local(word_pre) restore * word_post should be "bac" preserve sort order_post levelsof letters, local(word_post) restore gen word_pre = `word_pre' // this does not work as the letters are not concatenated
Comment