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

Reshape: Using previous variable labels to create a new string variable?

$
0
0
Hey everyone,

I have the following dataset:

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str14 Type float(ag1de_Plcyprob ag1de_PlcyForm ag1de_Implemen ag1de_Affected ag1de_PlcyLear ag1de_External obs_id)
"ag2di_Admin"    63.15789 94.73685      100  63.15789  47.36842 68.42105 1
"ag2di_Cooperat"       50       75      100        50        25      100 2
"ag2di_Economic" 44.73684 85.52631 94.73685  59.21053  28.94737 78.94737 3
"ag2di_Informat" 66.66667 83.33333      100 33.333336        50 83.33333 4
"ag2di_Regulve"        60       88 98.66667        64 34.666668 53.33334 5
end
And am reshaping it using this command:

Code:
reshape long ag1de_, i(obs_id) j(Category) string
Here's my question: I would like the new variable created "Category" to not consist of the previous variables names (e.g. "PlcyLear") but of the variable labels of the original ag1de_ prefixed variables (e.g. "Policy learning"). Do you have an idea how I could do this?

For your reference, here are the policy labels.

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str14 name str25 varlab
"Type"           ""                        
"ag1de_Plcyprob" " Policy problem/issue"    
"ag1de_PlcyForm" " Policy Formulation"      
"ag1de_Implemen" " Implementation Structure"
"ag1de_Affected" " Affected Groups"        
"ag1de_PlcyLear" " Policy learning"        
"ag1de_External" " External Factors"        
"obs_id"         ""                        
end

Thank you!

Viewing all articles
Browse latest Browse all 73275

Trending Articles



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