variables - How to change string value label -


suppose have string variable takes on several string values:

gen rand = runiform() sort rand gen var1 = "" replace var1 = "a" if rand < .3 replace var1 = "b" if rand>=.3 & rand < .7 replace var1 = "c" if var1=="" 

how change values of var1? example, a aaa, b bbb, , c ccc?

i want following (but rather replace variables), know incorrect:

label define var1l "a" "aa" b "bbb" c "ccc" label values var1 var1l 

string variables can't have value labels. can interpret if labels string variables meant content of variable itself. can replace:

clear set more off  input /// str1 var1 b c end  list  replace var1 = "aaa" if var1 == "a" replace var1 = "bbb" if var1 == "b" replace var1 = "ccc" if var1 == "c"  list 

you need more data , objectives more useful answer.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -