<>
" Wasnt aware of the possibility of referencing individual cells like that"
[U], 13.7., shows you the details...
BTW, my solution assumes a one to one mapping between col1 and col2, i.e.
no duplicates. If there are any, -duplicates drop- beforehand...
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of moleps
Sent: Sonntag, 3. Januar 2010 23:36
To: [email protected]
Subject: Re: st: RE: Setting label to adjoining column value
Beautiful.. Wasnt aware of the possibility of referencing individual cells
like that.. Thanks..
M
On 3. jan. 2010, at 23.26, Martin Weiss wrote:
>
> <>
>
> Just go for brute force then:
>
>
> *******
> clear*
>
> inp byte col1 str5 col2
> 1 "Table"
> 2 "Chair"
> end
>
> l, noo
>
> loc h ""
>
> forv i=1/`=_N'{
> loc h `h' `=col1[`i']' "`=col2[`i']'"
> }
>
> la def col1 `h'
> la val col1 col1
>
> //let`s see
> list, noob
> la li col1
> *******
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of moleps
> Sent: Sonntag, 3. Januar 2010 22:47
> To: [email protected]
> Subject: st: Setting label to adjoining column value
>
> Dear listers,
> I received an excel dataset with col1 identifiying productnumber, while
col2
> has the text variable for the productnumber.
> Col1 col2
> 1 Table
> 2 Chair
>
> etc.,etc
>
> Now what I´d like to do is to automatically generate a label for col1
> containing col2.
>
> local j=0
> global h=""
>
> levelsof col2,local (u)
> foreach var in `u'{
> local j=`j'+1
>
> global h $h `j'"`""`var'""'"
> di "$h"
>
> }
>
>
> lab define col1 $h
> lab val col1 col1
>
> The di "$4" displays everything as planned, except for the sorting that
has
> been carried out by levelsof. Is there workaround ? As of now the values
in
> the columns dont match.
>
> Regards,
> M
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/