Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: how to merge two variables into one


From   "b. water" <[email protected]>
To   [email protected]
Subject   RE: st: how to merge two variables into one
Date   Mon, 28 Nov 2005 09:37:38 +0000

thanks nick for your reply. it turns out that -trim()- was not what i was looking for. i managed to get what i want (99% of it in any case) by trial and error with helps from the manual (i looked at append, merge, trim and searched for concat, where i stumbled upon egen option that did the trick). this is the command that i used:

egen studynyr = concat (study year), punct(" ")

i tried to right justify the apperance of studynyr by adding format (%15s)

i.e.: egen studynyr = concat (study year), format (%15s) punct(" ")

but keep getting 'Invalid format'. however when i list the data, appearance seems to be as i like it so i might not have to force right justification but i would still appreciate advice on how to get the right justification command correct.

regards,
bw


From: "Nick Cox" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: RE: st: how to merge two variables into one
Date: Sun, 27 Nov 2005 16:43:57 -0000

When you say merge, I guess you mean
concatenate.

Assumed that you have applied -trim()-,
right-alignment is a matter of format,
not of what the values are, nor of how
they are held informally.

You should read up the help on formats.

Nick
[email protected]

b. water

> i have two variables: studynames and yearofstudy e.g. Alshop
> 1981, Bell 1992.
>
> what i want to do is to merge the two variables such that:
> Alshop 1981
>     Bell 1992
> i.e. somehow it is right-aligned in each cell.
>
> would be grateful for help in achieving this.
>
> platform: stata 8.2, os wxp pro sp2.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index