Announcement

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

  • Modified date variable

    In my dataset I have multiple observations for each IDs, sometimes even multiple observations each day. I am looking at counting the number of observations each day for each ID but I would like a modified data variable. Instead of looking at number of observations from midnight of one day to midnight of the next, I would like to look 3am to 3am for each date in the dataset. Any hints on how to do this?

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str7 clinicID float(date time firstintake) byte daily_reg float days_enrolled
    "M003834" 22770  1.967388e+12 22770 1  2
    "M003834" 22771  1.967449e+12 22770 1  2
    "M003984" 22768  1.967232e+12 22764 1  8
    "M003984" 22764 1.9668427e+12 22764 1  8
    "M003984" 22764  1.966843e+12 22764 1  8
    "M003984" 22765 1.9669305e+12 22764 1  8
    "M003984" 22769 1.9672747e+12 22764 1  8
    "M003984" 22764 1.9668423e+12 22764 1  8
    "M003984" 22768 1.9671887e+12 22764 1  8
    "M003984" 22766  1.967021e+12 22764 1  8
    "M003984" 22771 1.9674477e+12 22764 1  8
    "M003984" 22770 1.9673656e+12 22764 1  8
    end
    format %td date
    format %tcHH:MM time
    format %td firstintake

  • #2
    Subtract 1000*60*60*3 from each recorded time and generate a new time variable. Then use this new time variable to count.

    Comment


    • #3
      Rather than modify times I was hoping to create a new date variable that was 3am of that date to 3am of the next date....

      Comment


      • #4
        Just create the date from the modified time.

        Code:
        gen wanted= dofc(time-`=1000*60*60*3')
        format wanted %td

        Comment

        Working...
        X