Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: SV: Re: using by with graph


From   "Kim Lyngby Mikkelsen (KLM)" <[email protected]>
To   <[email protected]>
Subject   st: SV: Re: using by with graph
Date   Thu, 13 Dec 2007 20:28:27 +0100

Zhiqiang Wang and Nick Cox have written -longplot- that does exactly what you want.

findit longplot

I have been puzzling with a new version of longplot using the new graph features in Stata 10. I call my programme -longgraph-, but it is not really ready yet, but if you would like to try it out, here it is:

Copy the codes below and save it into -longgraph.ado-

Regards Kim

=======================================================================

*! 1.0.0 KLM 18 Nov 2007
program define longgraph, rclass
	version 10
	/* LONGGRAPH is inspired by 'longplot' (ZW & NJC 2001), but 
	compared 	to longplot, LONGGRAPH is rudimentary and simple 
	(although to the best of my current programming ability). Feel 
	free to improve it! */
	*
	/* like "longplot", LONGGRAPH graph values of a response variable
	yvar against a time variable xvar by groupvar such that each
 	group is shown by a distinct connected line with different colors
 	and markers, depending on which scheme is used.
	LONGGRAPH uses the valuelabels of groupvar for legend.
	LONGGRAPH allows for parsing of twoway_options such as title, 
	Axis and scheme using the graphopt(string) option. 	Connect_options can be specified using the C(option).
	Axis_choice_options is NOT implemented! However, the complete
 	twoway command can be retirved from the returmed local 
	macro: r(lg)
	(use: di "`r(lg)'") for further manual elaboration. */

	syntax varlist(min=2 max=2 numeric) [if/] [in]	///
	, BY(varname) [GRaphopt(string)] [C(string)]

qui levelsof `by', local(levels)
local N: word count `levels'
local if = "& `if'"
if "`c'" == "" {
	local c c(l)
}
else {
	local c c("`c'")
}
local cr
foreach l of local levels {
if `l'<`N' {
local cr  `cr'  scatter `varlist' if `by'==`l' `if' `in' ///
, legend(lab(`l' `: label (`by') `l' ' )) `c' sort ||
}
else {
local cr  `cr'  scatter `varlist' if `by'==`l' `if' `in' ///
, legend(lab(`l' `: label (`by') `l' ' )) `c' sort ||, `graphopt'
}
}
twoway `cr'
return local lg `cr'

end

============================================================

Kim Lyngby Mikkelsen
Stilling� 
Seniorforsker� 
Uddannelse� 
Cand.med. Ph.D.� 
Telefon� 
39165467� 
Email� 
[email protected]� 





All,

Sorry if this question is too simple, but here goes:

I have a panel dataset. I want to create simple graphs for each unit 
(called countrygroup) across time. Initially I tried -

by countrygroup: scatter data301 time

But Stata tells me by does not work with scatter. I then tried

scatter data301 time, by countrygroup

This works but Stata puts all the graphs on one page. There are over 100 of 
them so they are too small to be useful. Is there anyway I can see each 
graph on its own page? Or save them individually. Is there a command for 
this. I know I could use the if function but this seems time consuming.

P.S (I am using Stata version 8.2)

Thanks

Daniel Wilde


--On 12 December 2007 15:53 -0200 Jos� Maria Pacheco de Souza 
<[email protected]> wrote:

> It is always a pleasure to read any explanation given by Bill Gould.
> Jos� Maria
> Jose Maria Pacheco de Souza, Professor Titular (aposentado)
> Departamento de Epidemiologia/Faculdade de Saude Publica, USP
> Av. Dr. Arnaldo, 715
> 01246-904  -  S. Paulo/SP - Brasil
> fones (11)3082-3886; (11)3083-4246; (11)3061-7747; (11)3768-8612;
> (11)3714-2403
> fax (11)3082-2920; (11)3714-2403
> www.fsp.usp.br/~jmpsouza
> ----- Original Message ----- From: "William Gould, StataCorp LP"
> <[email protected]>
> Subject: Re: st: Stata stops recognizing basic commands
>
>
>> Jo La Frite <[email protected]> writes,
>>
>>> I am having a strange problem with Stata (Stata/SE 9.0 for Windows, I
>>> have
>>
>
>> Jo has already gotten lots of good advice from the list.  Some of that
>> advice, however, as been of the form of "do this and hope" and then
>> gone on to mention how serious the problem might be.  Jo, I fear, may
>> be more nervous than ever.
>>
>> Here's my advice:
>>
>>     1.  From what Jo says, it appears that somehow Stata's official
>>         ado-files got erased or that Jo or some system administrator
>>         made some change in Stata's parameters so that Stata can no
>>         longer find its official ado-files.
>> Good luck.  I've gone through this from start to finish just to prove to
>> you,
>> Jo, that no matter what happens, we have a plan on how to deal with it.
>>
>> I work for StataCorp so now I am required to add, since you are running
>> Stata
>> 9, that now might be a good time to consider upgrading to Stata 10, Jo.
>>
>>
>> -- Bill
>> [email protected]
>>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/





*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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