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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: RE: How to show formatted date variable in graph


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: How to show formatted date variable in graph
Date   Tue, 18 Oct 2011 08:48:07 +0100

You didn't answer the question on -tsset- but it seems that you did
not -tsset- these data, and very likely they could not be -tsset-.

No matter; my answer is the same. If the format you want is not
applied by default, you must apply it explicitly. In your case,
-histogram- is likely to be a convenient command.

clear
set obs 20
gen date = 150 + _n
gen ncopies = ceil(10 * runiform())
expand ncopies
format date %tq
histogram date, xla(, format("%tq")) frequency
histogram date, width(1) xla(151/170, format("%tq")) frequency discrete
histogram date, width(1) xla(151/170, ang(v) format("%tq")) frequency discrete

Nick

P.S. Writing all lower case may be easier for you but it makes your
postings more difficult to read. Please see Statalist FAQ 3.2.

On Mon, Oct 17, 2011 at 11:39 PM, paul o'brien <paul.obrien@afe2.org.uk> wrote:
> am not sure i have time series data, rather observations with data on
> events that occurred at a clinic visit, such as an particular drug was
> prescribed as on a particular date. what i want is simply a table of
> the number of visits at our clinics in each quarter. i have a variable
> quarter with for example, one observation having the value 151 when
> formatted appears in the browser as 1997q4. i simply want to produce a
> bar chart for the number of visits in each quarter with 1997q4 showing
> as one of the time periods.
>
> hope that makes sense.
>
> paul
>
> On 17 October 2011 19:13, Nick Cox <n.j.cox@durham.ac.uk> wrote:
>>
>> I'm surprised at this. Did you -tsset- your data?
>>
>> Graphs: A format such as you specify comes automatically in
>>
>> webuse turksales
>> tsline sales
>> line sales t
>> line sales t, xla(120(8)160)
>>
>> if you want something different, specify a -format()- suboption.
>>
>> line sales t, xla(120(8)160, format("%tqq_Cy"))
>>
>> Tables: Many tables don't even promise to echo the format of the variable being tabulated. More specific details are needed, I think.
>>
>> Nick
>> n.j.cox@durham.ac.uk
>>
>> Paul O'Brien
>>
>> i have a variable for the quarter of the year in which a clinic visit occurred which i have formatted thus:
>>
>> quarter 151 when formatted appears as 1997q4.
>>
>> when i create a table or graph of visits the number 151 appears rather than 1997q4.
>>
>> how to i get 1997q4 into the table and graph.
>>
*
*   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