BookmarkSubscribeRSS Feed
PhanS
Obsidian | Level 7

Hello everyone,

I am seeking SAS syntax for 'calculation person-year'. I am interested in looking an incidence rate of first stopping ARV in HIV populations.

I much appreciate anyone helps me with this concept.

Thanks in advance.

22 REPLIES 22
art297
Opal | Level 21

Couldn't you use the yrdif function (with the age option) to achieve what you want?  Take a look at:

http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p1pmmr2dtec...

Reeza
Super User

I think the OP is looking for the epidemiological aspect of person-year, which usually means changing your data structure. But it depends on what format the data is in and what question you're asking.

http://meds.queensu.ca/medicine/obgyn/pdf/what_is/What.is.person-time.pdf

AFAIK There isn't a PROC that can do that for you, you'll need to write your own datastep to solve it.

Doc_Duke
Rhodochrosite | Level 12

To follow up on Reeza and Art, the person-year of exposure to ARV would be the difference between the start of ARV and the first stopping (you can do with with yrdif or the approximate formula "(stopdate-startdate)/365.25".  To get the overall person-years of exposure, use PROC SUMMARY and get the sum.

Doc Muhlbaier

Duke

PhanS
Obsidian | Level 7

Hello,

Thanks for your contribution. I will follow-up later.

Thanks

Phan

PhanS
Obsidian | Level 7

Hello,

I do have the Eric document. I helps to understand the concept of person-year. I do agree with you that I have to write code my myself. At the meantime, I don't think I have never seen an example or taught about SAS syntax to apply for person-time.

It would be very helpful if any SAS experts can built an example for this issue for SAS users.

Thanks.

Phan

Doc_Duke
Rhodochrosite | Level 12

Try this Google search, you'll see lots of examples

person-year calculation site:sas.com

art297
Opal | Level 21

Phan,

I've never worked in the area of epidemiological research, thus am not aware of the various nuances described in the reference that  Fareeza provided.  However, I'd be interested in knowing why a calculation similar to the calculation of age wouldn't be relevant.

The following mimics one of the examples from that reference:

/*

Time contributed by each subject:

Subject A: 2.5 years

Subject B: 5 years

Subject C: 1.5 years

Subject 😧 5 years

Subject E: 0.5 years

*/

data have;

  informat initial_date onset_date date9.;

  format initial_date onset_date date9.;

  input subject $ initial_date onset_date;

  person_years=yrdif(initial_date, onset_date, 'AGE');

  cards;

A 01JAN2007 01JUL2009

B 01JAN2005 01JAN2010

C 01JAN2010 01JUL2011

D 01JUN2007 01JUN2012

E 01JUN2011 01DEC2011

;

: is that different from what the OP is seeking?

Reeza
Super User

That will give you the person-years per person, but then you need the proc summary as suggested by doc@duke.

  I'm a She not a He Smiley Happy

PhanS
Obsidian | Level 7

Dear Reeza,

My sincere apologies as I have difficulties with names. I appreciate and thank for your telling me.

Re. your advice, I will test later tonight and will follow-up.

Phan

Linlin
Lapis Lazuli | Level 10

Hi Reeza,

I didn't know either!:smileysilly:  Together we are going to change the belief "over the years, males
have dominated the SAS guru level (quoted from Art)". :smileysilly:

art297
Opal | Level 21

and   When I made the comment I was speaking historically.  I've been studying all of the SAS-L postings that have been made since 1986.  Each year, over that period, the most frequent posters were male.

I don't know if that holds true on the forum, but definitely see a change since at least two of the five with the most points are female.

PhanS
Obsidian | Level 7

Dear Art,

Many thanks for your follow-up. Through Reeze's comments, it appears that you are logic.

I may not have time to run a test at this moment, but will do tonight. I am happy to inform you.

Thanks,

Phan

PhanS
Obsidian | Level 7

Dear Art,

I am not sure the 'calculation person-age' is similar to 'person-year' that Reeza has mentioned. He provides a useful document about the concept of 'person-year'.

I am trying to build SAS codes and I would like to share if I achieved.

Thanks,

Phan

PhanS
Obsidian | Level 7

Dear Everyone,

My sincere apology that I couldn't get back last night.

To Art, I tested the yrdif (as well as dtdif) using methods/instructions from SAS Helps, unfortunately I had a message from log file: character values have been converted  to numeric values at the places given by ...

I am not sure what is wrong with the code.

Greatly, I used the approximate formula (doc@duke), it appears to be fine for my results.

As Reeze's comment, however, I need to develop several step fro proc summary, proc freq and proc mean to calculate 'sum' of variable that I need.

Overall, I think to calculate person-year is required several steps. These steps are very helpful for new SAS users like me.

One thing that I have no idea for Art is the code does not work. If possible, I will see a stat person in my place if he can help me to identify the erros.

At the meantime, I much appreciate and want to thank everyone in helping me this procedure. Again thanks.

Phan S. Smiley Happy

.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 22 replies
  • 12682 views
  • 6 likes
  • 5 in conversation