PDA

View Full Version : [STATA] - Adding space in merged variable



stataqueries
08-26-2010, 12:16 PM
Hi all,

I've got 10 different string variables that I want to consolidate into one so I did this:

gen newvar= var1+var2+var3+var4 etc

However when I did this, the info in my new variable is simply a long string of letters which is very difficult to read (it's a string variable). Is there a way to create this new variable whilst adding a space or punctuation or something between the different the inidividual variables?

Many thanks!

Link
08-26-2010, 12:49 PM
I'm not that good at STATA and don't have it in front of me right now. However, you should try gen newvar= var1+" "+var2+" "+var3+" "+var4 etc.

stataqueries
08-31-2010, 05:01 AM
Thanks so much! It worked. I got your reply and tried it straight away and it worked but I wasn't able to log on for some reason to send you a thank you immediately so here is a belated one.

Link
08-31-2010, 12:31 PM
Lol. You're welcome. Glad it helped.