Statalist


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

st: Setting label to adjoining column value


From   moleps <[email protected]>
To   [email protected]
Subject   st: Setting label to adjoining column value
Date   Sun, 3 Jan 2010 22:47:20 +0100

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/



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