Forum Navigation
You need to log in to create posts and topics.

DATAB Part 2: Creating a person-year table

Datab Part 2: Creating a person-year table.

This tutorial uses the study introduced in Part 1 to create a simple person-year table based on a subjects’ “year in”, “year out”, and “case status”. We create 5-year age categories and accumulate person-years and case counts into each stratum.

The mp4 file is the 10 minute tutorial.

The graphics file (.pdf) is attached. The script and logs are below:

DATAB Script:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! DATAB tutorial 2
! Create a cross-tabulated dataset based on the “How DATAB Works” tutorial
! Output files: tutorial_2_tab.bsf (binary file)
!                   tutorial_2_tab.csv @
!
!
! HIROSOFT INTERNATIONAL LLC
! August 2024
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! DATAB is a program to take individual records (persons) and
! count their accumulated person-years into categories
! that we define
!
! In this example, we will count person years and events to create rates
! The data that we will used is based on Slide 8 of the accompanying
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! To use DATAB, we define variables
! We then define categories to stratify the data in the variables
! Finally, we input the data. DATAB will then accumulate person years
! and count events into each of the categories that we defined.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! On the graphic in the accompanying tutorial, we see that there are
! 6 individuals in the study. Their age is the primary time category
! The study design starts at age 50 and ends at age 80.
! All person-time prior to age 50 or after age 80 is censored
!
! The input data includes the following variables
! ID: An arbitrary ID value, here we use 1-6
! Age_in: A participant’s age when they come under surveillance
! Age_out: A particpant’s age when they left the study
! Case: If they had the event at the time they left, this value is 1, else 0
!
! We begin by telling Epicure that we are starting a new project (i.e. clears
! the memory) and also that this is a DATAB session. The DATAB module will
! read individual records and create a stratified person-year table and event
! counts. Each command in Epicure is terminated with the ampersand “@”
new datab @
! We start by defining the variables that we will use
! using the NAMES command. Note, these are just variable names (placeholders)
! at this time. We will define categories using these variables, finally,
! we will input the data for these variable names
NAMES id age_in age_out case @
! now we define other information that DATAB needs
! Let’s start with a 5-year age categories from
! age 50 to age 80 (like the graphic). We use the
! DURATION command for ages that are not based on
! birth years and calendar date (we’ll see an example
! based on calendar dates in the next tutorial).
DURATION age_cat
50 (5) 80
@
! Next we tell DATAB which variable is the entry age
ENTRY age_in @
! Exit age:
EXIT age_out @
! Tell DATAB which variable indicates an Event
EVENT case @
! This is sufficient information for DATAB to compute
! person-years in 5-year time intervals and count events
! in each strata
!
! We are now ready to input the data using the INPUT
! command. Usually, we will read the data from a file but for
! this example, the data will be input directly from
! this script. Remember the variables are defined as:
!
! ID: An arbitrary ID value, here we use 1-6
! Age_in: A participant’s age when they come under surveillance
! Age_out: A particpant’s age when they left the study
! Case: If they had the event at the time they left, this value is 1, else 0
!
! We will not retype the variable names, simply the data separated by spaces.
! there are 4 variables. Each number will be put into the next variable, when the
! end of the list is found, it will repeat (the linefeeds are there for clarity).
INPUT < @
1 52 76 1
2 58 80 0
3 50 64 0
4 50 68 1
5 50 63 0
6 56 78 1
@
! At this point, the person-year table has been created
! Three variables were created based on our definitions
! PYR: person year in the strata
! age_cat: The age stratification we defined (5-year categories; age 50-80)
! case: a count of the number of cases in each strata
!
! another variable was created by DATAB “AT_RISK”
sum case @
sum pyr @
sum pyr by age_cat @
tran rate = case/pyr @
mean rate by age_cat @
!! Save the data to a CSV file
DATA TO tutorial_2_tab.csv @
!! Save the data to a binary “BSF” file
save; as tutorial_2_tab @
Log file:

[

Epicure/DATAB Version 2.00.04 (Oct 2023)
Gambarimashoo!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! DATAB tutorial 2
! Create a cross-tabulated dataset based on the “How DATAB Works” tutorial
! Output files: tutorial_2_tab.bsf (binary file)
!                   tutorial_2_tab.csv @
!
!
! HIROSOFT INTERNATIONAL LLC
! August 2024
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! DATAB is a program to take individual records (persons) and
! count their accumulated person-years into categories
! that we define
!
! In this example, we will count person years and events to create rates
! The data that we will used is based on Slide 8 of the accompanying
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! To use DATAB, we define variables
! We then define categories to stratify the data in the variables
! Finally, we input the data. DATAB will then accumulate person years
! and count events into each of the categories that we defined.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! On the graphic in the accompanying tutorial, we see that there are
! 6 individuals in the study. Their age is the primary time category
! The study design starts at age 50 and ends at age 80.
! All person-time prior to age 50 or after age 80 is censored
!
! The input data includes the following variables
! ID: An arbitrary ID value, here we use 1-6
! Age_in: A participant’s age when they come under surveillance
! Age_out: A particpant’s age when they left the study
! Case: If they had the event at the time they left, this value is 1, else 0
!
! We begin by telling Epicure that we are starting a new project (i.e. clears
! the memory) and also that this is a DATAB session. The DATAB module will
! read individual records and create a stratified person-year table and event
! counts. Each command in Epicure is terminated with the ampersand “@”
new datab @
! We start by defining the variables that we will use
! using the NAMES command. Note, these are just variable names (placeholders)
! at this time. We will define categories using these variables, finally,
! we will input the data for these variable names
NAMES id age_in age_out case @
! now we define other information that DATAB needs
! Let’s start with a 5-year age categories from
! age 50 to age 80 (like the graphic). We use the
! DURATION command for ages that are not based on
! birth years and calendar date (we’ll see an example
! based on calendar dates in the next tutorial).
DURATION age_cat
50 (5) 80
@
! Next we tell DATAB which variable is the entry age
ENTRY age_in @
! Exit age:
EXIT age_out @
! Tell DATAB which variable indicates an Event
EVENT case @
! This is sufficient information for DATAB to compute
! person-years in 5-year time intervals and count events
! in each strata
!
! We are now ready to input the data using the INPUT
! command. Usually, we will read the data from a file but for
! this example, the data will be input directly from
! this script. Remember the variables are defined as:
!
! ID: An arbitrary ID value, here we use 1-6
! Age_in: A participant’s age when they come under surveillance
! Age_out: A particpant’s age when they left the study
! Case: If they had the event at the time they left, this value is 1, else 0
!
! We will not retype the variable names, simply the data separated by spaces.
! there are 4 variables. Each number will be put into the next variable, when the
! end of the list is found, it will repeat (the linefeeds are there for clarity).
INPUT < @
Description of table:
    Variable             Category          Lower             Upper
Number     Name      Number     Name       Bound             Bound
    1      age_cat
                        1      50 – 55  [  50.00             55.00 )
                        2      55 – 60  [  55.00             60.00 )
                        3      60 – 65  [  60.00             65.00 )
                        4      65 – 70  [  65.00             70.00 )
                        5      70 – 75  [  70.00             75.00 )
                        6      75 – 80  [  75.00             80.00 )
           Summary Variables
    1) AT_RISK     2) PYR         3) case
             The potential number of cells is 6
Records read    —         6   Records used                    —         6
This table contains data in 6 with 6 variables
! At this point, the person-year table has been created
! Three variables were created based on our definitions
! PYR: person year in the strata
! age_cat: The age stratification we defined (5-year categories; age 50-80)
! case: a count of the number of cases in each strata
!
! another variable was created by DATAB “AT_RISK”
sum case @
           Summary for case
                Sum         Count      Minimum      Maximum
                  3             6            0            2
sum pyr @
           Summary for PYR
                Sum         Count      Minimum      Maximum
                113             6            9           27
sum pyr by age_cat @
           Summary for PYR
age_cat           Sum         Count      Minimum      Maximum
    1            18             1           18           18
    2            26             1           26           26
    3            27             1           27           27
    4            18             1           18           18
    5            15             1           15           15
    6             9             1            9            9
tran rate = case/pyr @
mean rate by age_cat @
           Summary for rate
age_cat          Mean      Std. Dev.        Count      Minimum      Maximum
    1             0             0             1            0            0
    2             0             0             1            0            0
    3             0             0             1            0            0
    4     0.0555556             0             1     0.055556     0.055556
    5             0             0             1            0            0
    6      0.222222             0             1      0.22222      0.22222
!! Save the data to a CSV file
DATA TO tutorial_2_tab.csv @
6 records written to tutorial_2_tab.csv
!! Save the data to a binary “BSF” file
save; as tutorial_2_tab @
6 records written to tutorial_2_tab.BSF

]

Uploaded files: