Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Export Output into Multiple Excel Worksheets


From   Lisa Wang <lhwang0925@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Export Output into Multiple Excel Worksheets
Date   Thu, 2 Aug 2012 10:01:02 +1000

Hi Scott,

That was fantastic! Exactly what I wanted. Thank you very much. It
saved me a lot of time without have to do it manually myself in Excel.

Have a great day,
Lisa

On Thu, Aug 2, 2012 at 3:22 AM, Scott Merryman <scott.merryman@gmail.com> wrote:
> clear
> input id str5 name str3 time
> 313 Lisa R14
> 22415 Tom T15
> 636 Jack W9
> 4546 Sam R14
> 870 Jenny W9
> end
>
> levelsof time, local(levels)
> foreach l of local levels {
>         export excel using "C:\Users\scott.merryman\Desktop\example.xlsx" ///
>          if time =="`l'", sheet("`l'") firstrow(variables) sheetmodify
> }
>
>
> Scott
>
>
> On Wed, Aug 1, 2012 at 3:35 AM, Lisa Wang <lhwang0925@gmail.com> wrote:
>> Hi all,
>>
>> I have imported some data from Excel into Stata. What I would like to
>> know is how to get Stata to recognise the category ('Time') and then
>> group the observations from the same categories together and then
>> export the observations of the same category into one worksheet.
>>
>> Example,
>>
>> ID Name Time
>> 313 Lisa R14
>> 22415 Tom T15
>> 636 Jack W9
>> 4546 Sam R14
>> 870 Jenny W9
>>
>> From the above rows, I would like to end up with three worksheets in
>> one Excel workbook - in sheet 1: I would have two rows corresponding
>> to Lisa and Sam corresponding to R14, sheet 2: one row for Tom as T15
>> and in sheet 3: two rows for Jack and Jenny for W9.
>>
>> So, in effect, what I would like is Stata to sort, categorise and then
>> copy my data to Excel worksheets. Is this possible or not?
>>
>> Many thanks,
>> Lisa
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index