Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: Setting label to adjoining column value


From   Eric Booth <[email protected]>
To   [email protected]
Subject   Re: st: RE: Setting label to adjoining column value
Date   Sun, 3 Jan 2010 18:26:53 -0600

<>

Also, NJC's -labutil- utilities are useful for dealing with labels in various ways.  
In this case you could use  -labmask- :

*******
clear*
inp byte col1 str5 col2
1 "Table"
2 "Chair" 
end

ssc install labutil
labmask col1, values(col2) lbl(label)
la li label
*******

~ Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754




On Jan 3, 2010, at 4:51 PM, Martin Weiss wrote:

> 
> <>
> 
> " 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/



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