Hi,
I am new to programming in SAS. I have count data for prescriptions in each year of the study. Each row has the number of prescirpitons in that uear, the person-time, the rate and the ln(person time). I want to use proc genmod to calculate the rate ratio:
1) Between each year of the study compared to the first year of the study (1998) as a reference
2) Between each year of the study and the previous year (i.e. 1999 to 1998, 2000 to 1999 etc)
I am having trouble to set my estimate statement in the code so I will get the rate ration for each year.
This is my data structure:
Yearrx | RX | PT | rate | lnPT |
1998 | 100 | 135 | 0.740741 | 4.905275 |
1999 | 200 | 480 | 0.416667 | 6.173786 |
2000 | 250 | 950 | 0.263158 | 6.856462 |
2001 | 300 | 1100 | 0.272727 | 7.003065 |
2002 | 350 | 2100 | 0.166667 | 7.649693 |
2003 | 450 | 2500 | 0.18 | 7.824046 |
Hoe should my code look like?
proc genmod data=h2only ;
Class Yearrx (ref="1998");
model rx=Yearrx /dist=negbin scale=deviance offset=ln;
estimate '1998' Yearrx 1 -1;
estimate '1999' Yearrx 1 -1;
estimate '2000' Yearrx 1 -2;
run;y
Don't use ESTIMATE statement to compare levels. Use the LSMEANS command.
lsmeans yearrx / cl lines linestable;
You may not want all of those options, but that is where I would start.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.