Announcement

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

  • Creating a new variable called "Wave" and select a range of "dates" from a date variable corresponding to this wave

    Dear all, I am currently analysing a data set on COVID-19. The data are arranged by each date from 16 March 2020 to 30 April 2023. I have four variables in my dataseti) Date; (ii) Tests performed; (iii) Cases; and (iv) Deaths. The dates variable is appropriately formatted for STATA. The rest of my variables are numeric. We have observed four or five epidemic waves of COVID-19 in a country, and I am analyzing the data set of this country where these waves were seen/observed. I would like to see how many cases and deaths were reported and COVID-19 tests performed for each wave, and as such, I would like to segregate the number of cases, deaths, and tests performed in my dataset according to Wave-1, Wave-2, etc. I know the start and end date of each wave. However, my challenge is how to select the data on cases, deaths and tests performed by a particular range of dates (say from 06 April 2020 to 7 August for the first wave, 25 August 2020 to 15 January 2021 for the second wave, etc.). My ultimate aim is to compare these epidemiological characteristics (cases, deaths, tests, and some other analysis like CFR, tests/case ratio, etc.) by waves and calculate the statistical significance of the differences between the waves, if any. Any help or assistance that I get from any one of you on how to do this (segregation of data on cases, deaths and tests performed by a selected range of date) will be very much appreciated. Thanks a lot.

  • #2
    Originally posted by Mamunur Rahman View Post
    . . . my challenge is how to select the data on cases, deaths and tests performed by a particular range of dates (say from 06 April 2020 to 7 August for the first wave. . .
    Maybe try something like the following.
    Code:
    frame put cases deaths tests if inrange(date, date("2020-04-06", "YMD"), date("2020-08-06", "YMD")), into(FirstWave)
    My ultimate aim is to compare these epidemiological characteristics (cases, deaths, tests, and some other analysis like CFR, tests/case ratio, etc.) by waves and calculate the statistical significance of the differences between the waves . . .
    For something like that, you can create a new variable, say, wave, using the same general selection criterion.
    Code:
    generate byte wave = ///
        inrange(date, date("2020-04-06", "YMD"), date("2020-08-06", "YMD")) + ///
        2 * inrange(date, date("2020-08-25", "YMD"), date("2021-01-15", "YMD")) + . . .
    Last edited by Joseph Coveney; 04 Oct 2025, 01:10.

    Comment


    • #3
      Thank you, Joseph. I will try it out and see if I face any challenges.. Thank you so much. Appreciated.

      Comment


      • #4
        You're welcome, Mamunur. Feel free to get back to the List if you encounter any difficulties. Be sure to monitor the List in the interim: others here might have more elegant or more workable solutions to offer.

        Comment


        • #5
          Thank you

          Comment

          Working...
          X