Time series in Stata®, part 1: Formatting and managing dates

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 82

  • @avinashsingh5242
    @avinashsingh5242 4 роки тому

    Thanks a lot Sir. I was messed up for so long until I watched your video. Everything is sorted now. Doing my research paper.

  • @statacorp
    @statacorp  11 років тому +3

    If your data are measured in hours or minutes, the process will be essentially identical. You will need to format your time variable in hours or minutes (see help datetime_display_formats). When you use -tsset- you can use the options -clocktime- and -delta(30 minutes)- to specify the time interval you would like (for a worked example see help tsset).

    • @jingnanli7325
      @jingnanli7325 2 роки тому

      what if you have more firms. your data is only about one firm. with two firms, one firm has 2009-2020, seond firm has 2009-2020

    • @statacorp
      @statacorp  2 роки тому

      @@jingnanli7325 With panel data you would specify the panel identifier and time variable with *tsset* . For example, *tsset company year, yearly* . Please refer to Example 8 in
      [TS] tsset for an example with panel data (www.stata.com/manuals/tstsset.pdf). You can also use *tsfill* with panel data. Please type *help tsset* and *help tsfill* to learn more.

  • @carlospenaherrera6624
    @carlospenaherrera6624 9 років тому +11

    Hello I have a panel data series and I need to declare a variable as a time series variable, the problem is that I have several observations for example, for quarter 1, and it doesnt allow me to declare my variable as time series because it says that there are "repeated time values within panel"

    • @mehan98
      @mehan98 2 роки тому

      Did you ever figure this out? I have the same issue.

  • @dimitris303
    @dimitris303 7 років тому +2

    WOOW!!! THIS VIDEO IS EXTREMELY IMPORTANT AND VERY HELPFUL!!!
    THANKS A LOT!

  • @isabelcaldeira
    @isabelcaldeira 3 роки тому

    This video was extremely helpful! Thank you so much!

  • @beverley7220
    @beverley7220 4 роки тому

    Thank you!! I couldnt get the 'data2' row for ages but turns out I typed in 'Data' instead of 'data' :)

  • @kakandeelijah9426
    @kakandeelijah9426 4 роки тому +1

    How do I go about sample size and power calculations for a time series analysis design?

  • @versystudio822
    @versystudio822 5 років тому +1

    Sorry, I'm new to stata. I download FRED's US GDP data. When I want to declare it as time-series, I indicate daten as quarterly time variable. The dataset is based on quarterly numbers. However, stata warns me that it thinks the dates are 'formatted %tdnn/dd/CCYY (a daily period)' and says there are gaps. And I know there aren't. If I fill gaps it creates 90 empty days between each of real ones. I tried to create a new date variable with the same problems. Can you help, please?

  • @bangecon
    @bangecon 9 років тому

    This is helpful. However the example appears to be "business week" daily data. If I'm not mistaken there is an option in the date or other time series formatting commands that lets you ignore weekends and holidays, at least based on the US calendar.

    • @statacorp
      @statacorp  9 років тому

      Thanks! The option you are looking for is called "business calendars" and you can learn more about them here: www.stata.com/manuals13/dbcal.pdf

  • @andreeapalici3970
    @andreeapalici3970 4 роки тому +1

    I created a business calendar (format mdy). When I wrote: omit date 1/1*, Stata omitted Jan 1st (OK), but also Jan 11(not OK), for all years in the dataset. If I wrote omit date jan 1*, I got the same as above. How can I write the command so that Stata omits only Jan 1st?

    • @cassiesevigny
      @cassiesevigny 3 роки тому

      Stata interprets * as any value that occurs in that position. Maybe try 1/1/*?

  • @sahilnarang2986
    @sahilnarang2986 3 роки тому

    Thank you, this is helpful!

  • @MazzuAlex
    @MazzuAlex 10 років тому +4

    My dates are listed as 2008q1, 2008q2, etc. how do I format these dates?

    • @darryl47nopra
      @darryl47nopra 10 років тому

      Same question!

    • @displayname2149
      @displayname2149 7 років тому

      I believe it would be format 'x' %tq
      With x being your variable's name

    • @AnimaInCarbonio
      @AnimaInCarbonio 6 років тому

      format quarters %td

    • @junfeima8943
      @junfeima8943 5 років тому +3

      The argument is for quarterly is "generate date=quarterly(date, "YQ")"

  • @saharloukil7168
    @saharloukil7168 2 роки тому

    very helpful thank you very much

  • @jayko3997
    @jayko3997 9 років тому +1

    Hi, I'm following the steps but it's generating "Date2" with missing variables. Any idea why this is? My "Date" variable is yearly ( 31-12-03) for 356 observations for 4 years between 03-06

  • @statacorp
    @statacorp  11 років тому

    Google "DJIA data" - there are many sources for that data on the web. You could also watch the video on "freduse" which would allow you to download the "DJIA" data using one command in Stata.

    • @archiej6386
      @archiej6386 4 роки тому

      any way to do this with quarterly interval data

  • @oowilliamm
    @oowilliamm 8 років тому +3

    My dates are shown as 1998/1999 (start year/end year) and I have no idea how to work with that

  • @ronakmaheshwari9667
    @ronakmaheshwari9667 4 роки тому

    What can I do if my dates are in the format 1950-1951 and so on...?

  • @145kick
    @145kick 3 роки тому

    Thank you!!

  • @HDWoodMoviesDotCom
    @HDWoodMoviesDotCom 11 років тому +1

    what if we do not have to show date..just month and year ?

    • @statacorp
      @statacorp  10 років тому +1

      You can format his date variable using:

  • @sophieselbe
    @sophieselbe 6 років тому +1

    What if your dates are in month/day/year form for example 1/1/2018?

  • @baloo5949
    @baloo5949 4 роки тому

    Hey! Im desperately in need of your help!!! My data set is string daily (without the weekends)
    I've tried formatting the data using the command: generate time=date(date, "MDY") but it keeps responding with "missing values generated".
    Please help me i've tried everything and nothing works. My data is 01/01/1991 (MDY) and its called date but i dont know why it isnt working

  • @zeitgeistbjm4083
    @zeitgeistbjm4083 4 роки тому

    Hi, thanks for sharing the knowledge, could you share the data set used?

  • @antoinethompson-leduc7687
    @antoinethompson-leduc7687 9 років тому

    Thank you, very helpful!
    I have many data / moment,
    repeated time values in sample
    can I still do it?

  • @챨리-q1j
    @챨리-q1j 8 років тому +1

    Hi, thank you for your video. Can I ask you something related to your post?
    I was trying to convert a string variable (the variable name is obs) into a float variable like you did. But since I have quarterly observations, I used " data(obs, "YQ"). But when I looked at the screen, all of my column cells were filled with one dot. But I just hoped to proceed to do some analysis and I clicked on some statistics option, then I had an error message on the screen. "No observations". How can I fix this problem? I will look forward to your reply. Thanks.

    • @FAAK27
      @FAAK27 8 років тому

      same problem here

    • @doudadada9552
      @doudadada9552 6 років тому

      Hi ,
      Same problem here
      I wonder if you get to fix it
      I look forward for your reply
      Thanks

  • @KezSingChong
    @KezSingChong 4 роки тому

    Instead of filling time gaps, can I create business calender?

  • @99ers1
    @99ers1 9 років тому +1

    My dates are 1991q1, 1991q2, 1991q3,... (exactly this format) and they are string variables. How can i use or prepare them for a time series??

    • @19lovesinging
      @19lovesinging 3 роки тому

      Did you end up figuring this out 6 years ago?

  • @kutinnikola
    @kutinnikola 8 років тому +3

    Hi in Excel the dates are written such as: 3/1/2015; 4/1/2015 ... (March, 1, 2015, April 1, 2015...) --> However my data are monthly statistics, how shell I transform these data into monthly without having 30 gaps between each observation?

    • @jrihal7353
      @jrihal7353 6 років тому +1

      @kolio000 have you figured out how to fix this I am having the same issue?

  • @FernandoRomero-mq6jb
    @FernandoRomero-mq6jb 3 роки тому

    Please, a query: I am analyzing a time series and I am applying natural logarithms, in one of the variables I have two data "zero" (0), there is no natural logarithm for zero, I ask, to save this problem, can I assign it to the data a number close to zero, example 0.001 (or similar)? Thanks.

  • @laoiserenwick3673
    @laoiserenwick3673 10 років тому +1

    Very helpful video, thank you. Can you please tell me if it's possible manage dates like this with additional subdivisions i.e. am, pm night shift (say, on a hospital ward). Thanks

    • @statacorp
      @statacorp  10 років тому

      I think that most organizations that deal with 24 hour time cycles (like hospitals) use military time: display clock(5-12-1998 15:15, MDY hm)

  • @shoaibhassan8918
    @shoaibhassan8918 7 років тому

    Anyone knows how to do epicurve in Stata? For outbreak investigations purposes - cannot find any relevant support. Thanks

  • @sadeghghazanfari
    @sadeghghazanfari 10 років тому

    Very helpful video, thanks

  • @mrpap93
    @mrpap93 9 років тому

    encode variable, gen(variable1)
    Can you fix the string with this command?

  • @chhatiune
    @chhatiune 8 років тому

    My date appears as 2000-01, 2001-02 and so on. How to use them for line graph plot in stata? I have no idea.

    • @displayname2149
      @displayname2149 7 років тому

      I don't think that would matter too much in terms of plotting a graph. As long as Stata recognises your time variable's name.
      I'm not an expert by any means, rather more a beginner than anything but try
      graph twoway line (Y. year)
      where Y is your Y axis, assuming you're plotting time along the x axis.

  • @abobakermomed9324
    @abobakermomed9324 7 років тому

    Hi,
    Please, can you explain briefly how can I run cross sectional regrecession in a time series data? please it is very important to me. I would like to calculate the residuals from time series data ,but cross sectionally.

  • @samuelcosta73
    @samuelcosta73 11 років тому +1

    Thank you for your videos, they are all really helpful.
    Could you explain how to create a timeseries dataset by copying and pasting time series data from excel?
    I created a 9 provinces dataset with several variables, in a time series of the last 30 years. How can I tell STATA how to recognize the provinces and the different variables?

  • @github921
    @github921 10 років тому

    Sir, I am working with Indian GDP data, which comes out every quarter. But here, Q1 is April-June, Q2 is Jul-Sep, and so on. Please suggest how I can format this kind of data for time-series graphing etc in Stata. Thanks a lot for the video-lesson!

    • @statacorp
      @statacorp  10 років тому

      Thank you for your question. Please contact technical services with your question at www.stata.com/support/tech-support/contact. They should be able to assist you with this.

  • @johndupont8596
    @johndupont8596 9 років тому

    Hi there,
    Thank you very much for the video. I just have one question, I get the error "repeated time values in sample" as I am looking at the effect on more than one country therefore I have multiple dates. How could I take this into account?
    Thank you very much!
    John

    • @kepoh09
      @kepoh09 5 років тому

      Hi, did you able to solve this? If yes, hope you could share the method to solve this issue? would really appreciate it. Thank you in advance

    • @cassiesevigny
      @cassiesevigny 3 роки тому

      Maybe try using the panel command xtset instead? this allows you to designate time variable and an identifying variable - so yours might look like xtset [time/date] [country]. Then Stata recognizes there are values for each country within each time period. As long as you don't have the same country listed with the same date more than once, this will work.

    • @cassiesevigny
      @cassiesevigny 3 роки тому

      @@kepoh09 try using xtset instead

  • @sami-samim
    @sami-samim 7 років тому

    Why do I get a negative number in converting the date?

    • @collinfrancis2053
      @collinfrancis2053 7 років тому +1

      a negative number means a date before January 1, 1960

  • @JesseGoldman
    @JesseGoldman 11 років тому

    Where can this data be downloaded for practice?

  • @statacorp
    @statacorp  11 років тому

    Check out the video "Copy/Paste Data from Excel into Stata" on our channel.
    The process is identical for any kind of data.
    For your second question, take a look at the format of this dataset:
    webuse stocks
    Once you "tsset" the data, you can graph or model the data as you wish:
    tsset t, daily
    tsline toyota nissan honda

  • @owenjrable
    @owenjrable 10 років тому

    It would be helpful if I could be able to download this data so I could follow along. Where can I download this?

    • @statacorp
      @statacorp  10 років тому

      You can copy and paste the data from Yahoo Finance here: finance.yahoo.com/q/hp?s=^DJI+Historical+Prices

  • @AdeelYousaf
    @AdeelYousaf 11 років тому

    please upload video for generating time series graph using hourly or minutely data

  • @jingnanli7325
    @jingnanli7325 2 роки тому

    how about my "date" is quarterly

    • @statacorp
      @statacorp  2 роки тому

      You can use the *quarterly()* function to convert quarterly dates stored as strings to a numeric quarterly date. Then, you would use the %tq display format. To learn more about working with dates, please type *help dates* in the Stata Command window.

    • @jingnanli7325
      @jingnanli7325 2 роки тому +1

      @@statacorp thank you so very much. very helpful

  • @xuewang6100
    @xuewang6100 11 років тому

    why i got missing values like this
    ". generate date2 = date(Date,"MY" )
    (163 missing values generated)"
    "

    • @statacorp
      @statacorp  10 років тому

      You left the out of his date function. It should be:

    • @joesr31
      @joesr31 6 років тому

      what if I only have month and year, is it possible to do it without day?

  • @Lyno1233
    @Lyno1233 7 років тому

    Gracias¡¡ eres muy amable

  • @adafridi
    @adafridi 7 років тому

    Gretl is far more easy to use software than Stata. Unfortunately, there aren't many video available on UA-cam about it.

  • @FAAK27
    @FAAK27 8 років тому

    Ohh whyyy ?? why y no make it more easy ???

  • @owenjrable
    @owenjrable 10 років тому

    Not helpful