Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Export Output into Multiple Excel Worksheets


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: Export Output into Multiple Excel Worksheets
Date   Wed, 1 Aug 2012 12:22:05 -0500

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 <[email protected]> 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index