Dear all,
Hi, I have two questions regarding real() function and destring command.
I have string variables that are actually numbers, e.g., "230,000". If I am correct, real("230,000") generates a missing value and doing destring is not possible (unless you command ignore).
My first question is, can Stata recognize "230,000" is a number? Quintessentially, I want a function like real(), except that it will NOT generate a missing value and rather generate 230000.
Now, suppose I have multiple variables, assets196001, assets196001, ... assets201412 (i.e., assetsYYYYMM). I tried, destring assets*, gen(destr*), but it seems that gen(destr*) is the problem. I'm guessing that I cannot use * in gen() to refer to a pattern in the reference variable names.
My second question is, can I somehow use * trick to generate new multiple variables, or do I have to literally type gen (destr196001 destr196002 destr196003... destr201412)?
I'd greatly appreciate your advice and guidance. Thank you very much in advance!
Best,
John
Hi, I have two questions regarding real() function and destring command.
I have string variables that are actually numbers, e.g., "230,000". If I am correct, real("230,000") generates a missing value and doing destring is not possible (unless you command ignore).
My first question is, can Stata recognize "230,000" is a number? Quintessentially, I want a function like real(), except that it will NOT generate a missing value and rather generate 230000.
Now, suppose I have multiple variables, assets196001, assets196001, ... assets201412 (i.e., assetsYYYYMM). I tried, destring assets*, gen(destr*), but it seems that gen(destr*) is the problem. I'm guessing that I cannot use * in gen() to refer to a pattern in the reference variable names.
My second question is, can I somehow use * trick to generate new multiple variables, or do I have to literally type gen (destr196001 destr196002 destr196003... destr201412)?
I'd greatly appreciate your advice and guidance. Thank you very much in advance!
Best,
John
Comment