Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Assign variable labels after importing data from Microsoft Excel |
Date | Mon, 19 Mar 2012 19:00:51 +0000 |
Eric's suggestion is good, but I know no reason to call -destring- repeatedly. Instead of foreach x of varlist * { cap destring `x', replace } try destring , replace as much of the code in -destring- is devoted to dealing with existing string variables or other problems gracefully. Nick On Mon, Mar 19, 2012 at 6:43 PM, Eric Booth <eric.a.booth@gmail.com> wrote: > ********* > clear > input str15 (id time var1 var2 var3) > label_id label_time label_var1 label_var2 label_var3 > 1 1960 123 1234 a34 > end > > ** > foreach x of varlist * { > label var `x' `"`=`x'[1]'"' > } > drop in 1 > foreach x of varlist * { > cap destring `x', replace > } > desc > ******** > On Mar 19, 2012, at 1:30 PM, Iulian Ihnatov wrote: >> I need to import a Microsoft Excel sheet content (panel data) in Stata 12 that looks as follows: >> id time var1 var2 var3 ..... >> label_id label_time label_var1 label_var2 label_var3 ... >> 1 1960 123 1234 234 >> ... >> >> My problem is to use the values of the second row as value labels for the variable names in the first row. The - import excel - part is the easy one. I looked through the variable label management modules on the SSC archive and could't find an appropriate package to solve my problem. Thus, any help would be highly appreciated. * * 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/