BookmarkSubscribeRSS Feed
nwang5
Obsidian | Level 7

Hi all,

 

I hope you are doing well. I am trying to calculate person years. I am not sure if there is any code we can use in proc phreg to get person year and number of events directly.

 

I also have another question. I selected participants who did not have health outcome and try to calculate person year by hand. I was wondering if there is any code I can use to get the sum of each product of each column* time: h:persist good person time=2*176+4*340+6*272+.......

 

 

Table of time by hear_p4cat
time hear_p4cat
h:persist good h:poor to good h:good to poor h:persist poor Total
2
176
25
18
19
238
4
340
29
39
68
476
6
272
37
33
51
393
8
319
21
33
36
409
10
229
22
26
30
307
12
247
24
17
31
319
14
1275
63
79
143
1560
Total
2858
221
245
378
3702

 

Thanks!

1 REPLY 1
ballardw
Super User

Please provide example data in the form of data step code. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

If you can't manage that at least post the example as simple text in a text box. That particular tabular layout is not worth trying to write a data step with.

 

My first thought would be Proc Means/ summary with your Time variable as a Weight variable and then request a Sum for the other variables. DO not include the Total row, if you have such in your actual data set, as it is obviously not a numeric variable and a Weight variable must be numeric.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 263 views
  • 0 likes
  • 2 in conversation