## How to make a time-dependent variable

Occasional Contributor
Posts: 7

# How to make a time-dependent variable

Hi Everyone,

What I have:

I have three variables, Year_of_visit, employment status (UNEMP), and HIV_ status. I also have 5 participants. Participants were asked about their employment status in different years. When the UNEMP is 0 it means the person is employed and when it is 1 it means the person is not employed. In each year of visit, they were also tested for HIV status. If HIV test is 0 then the person is not infected if HIV_status is 1 then they are infected.

What I want:

I am conducting a survival analysis (using PROC PHREG) on the association between the Unemployment (UNEMP) and HIV outcome. However, the employment status of participants changes in different years. For instance, Case ID 1 is employed in years 2000 and 2001, then she was unemployed in years 2002 and 2003, and finally, she became employed again in 2004. Hence, the Unemp variable is time-dependent and changes over time. I want to make a third time-dependent variable based on UNEMP variable, which takes into account the time dependency of Unemp. Then I am going to use that variable in Proc Phreg analysis.

Thank you indeed for your help. Below is a code for what I have.

Data what_I_Have;

input CASE_ID Year_of_visit UNEMP HIV_Status ;

Datalines;

1 2000 0 0

1 2001 0 0

1 2002 1 0

1 2003 1 1

1 2004 0 1

2 2000 0 0

2 2001 0 1

2 2002 1 1

2 2003 1 1

2 2004 1 1

2 2005 1 1

3 2000 1 0

3 2001 1 0

4 2000 1 0

4 2001 0 0

5 2000 1 0

5 2001 1 0

5 2002 0 1

5 2003 1 1

;

Valued Guide
Posts: 516

## Re: How to make a time-dependent variable

Sorry, but i don't understand what "time-dependent" means. Please explain what the variable should contain.

Occasional Contributor
Posts: 7