Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question:

    I'm currently using Stata for a research I'm doing and I have the following issue:
    I have a column is the numbers 0 till 2103839 each row the following number (0, 1, 2, 3 etc). I would like to make a 2nd column that shows the hourID (0-60: 1, 61-120: 2, etc) how do I do this?

    Thanks in advance

  • #2
    Welcome to Statalist.

    It seems odd that the first 61 numbers (0-60) become hour 1, and after that, each group of just 60 numbers (61-120, for example) become a different hour. So hour 1 has one additional observation? And I note that your list of numbers ends at one less than than a multiple of 60. So I think what you want is 0-59 become 1, 60-119 become 2, ..., up to 2103780-2103839 become 35063. This untested code does that.
    Code:
    generate hour = 1+floor(minute/60)
    With that said, please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Calling your topic "question" doesn't draw the attention of members who might be able to help you, and with so many questions asked, the better your title highlights the nature of your problem, the more members are likely to read it.

    Comment


    • #3
      Hi William, thank you very much!! This really helped me

      Comment

      Working...
      X