![]() ![]() Option where we can supply in valid format that we would supply We can change the format of the display of the date variable using the format() graph twoway tsline high low, tlabel(01apr2001 01jul2001 01oct2001) Ttick(), tmlabel(), tmtick(), and tscale(), seeĭetails. Other options that can be used in a similar way include For example, say that we wanted the x axis to be labeled Understand that the x axis is a date variable and are much easier to In addition to these benefits, there are options we can use that Next, note that the labels for the xĪxis are labeled much better with more logical values having been chosen. This is because Stata knew, from the tsset command, what the time Note that we did not need to specify date in the command. Now we can use graph twoway tsline to graph the data. Time variable: date, 02jan2001 to 31dec2001, but with gaps To tell Stata that the variable date represents time and that its Graph twoway line we can use graph twoway tsline which is specifically designed for making line graphs where the Labeling the x axis since these are date values. Also, it could be difficult to change the values Properly labeled with the dates, but the selection of the values labeling thisĪxis could be better. ![]() We could use the graph twoway line command to graph the high and low closing price for the year, as shown below. ![]() High and low trading price for a given day and date which is a date This file has variables like high and low that represents the This data file contains data for all of the trading days in 2001. This FAQ shows examples of graphing data where the x axis represents dates.įor these examples, we will use the sp500 dataįile that comes with Stata and we can use it via the sysuse command. 20000 is not a plausible monthly date for most Stata users, as it is for some 1600+ years into the future. If this is off-target, you may need to supply real data and code details, not just mention what you used in an incomplete description. The effect of those functions is to change (most) values, after which the appropriate display format can be assigned.Īs you should see, strategic advice here is to try out solutions by hand using display. This is tricky, but it is all well documented at help dates and times, just in more detail than most people want to read, as you have to skim and skip whatever doesn't apply to your immediate need.Īs I understand it, your problem in a nutshell is converting monthly dates to quarterly dates, and for that you don't need to extract month and year as you suppose, although that's one route. ![]() On top of that, if you have monthly dates, year() and month() can't help without extra functions, as they extract years and months from daily dates. So, changing the display format without changing the values is often just a recipe for nonsense. If I assign it date format %td, %tm, %tq I get shown different dates, but at most one can be correct, as I changed nothing except the display format. So changing the display format changes the Stata date type.Ībsolutely not! For example, suppose I have a number 42. Still, some diagnosis is possible.Īssigning a particular date display format defines a Stata date Strictly, that renders your question off-topic here, as there is nothing like a reproducible example in your question. You mention several linked problems here without once giving examples showing your exact code used or your real data. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |