We can see the results of the test of association in the Results Viewer: Lastly, we can use proc sql to store our summary statistics & use these to calculate the test of heterogeneity for the CIR: /*Test of Heterogeneity: CIR*/ /*Store MH CIR for H statistic calculation*/ proc sql noprint; select sum(MH_numerator_term_i)/sum(MH_w_i) into :MH_CIR from stratified_closed; quit; proc sql; title 'Tests of Homogeneity: CIR'; select sum(((log(CIR_i)-log(&MH_CIR))**2)/Variance_CIR_confint_i) as H_CIR, 1-probchi(sum(((log(CIR_i)- log(&MH_CIR))**2)/Variance_CIR_confint_i), (count(*)-1)) as p, count(*)-1 as DF from stratified_closed; quit; We can see the results in the Result Viewer:
And for the CID: /*Test of Heterogeneity: CID*/ /*Store IV CID for H statistic calculation*/ proc sql noprint; select sum(IV_numerator_term_i)/sum(IV_w_i) into :IV_CID from stratified_closed; quit; proc sql; title 'Tests of Homogeneity: CID'; select sum(((CID_i-&IV_CID)**2)/Variance_CID_confint_i) as H_CID, 1-probchi(sum(((CID_i-&IV_CID)**2)/Variance_CID_confint_i), (count(*)-1)) as p, count(*)-1 as DF from stratified_closed; quit; We can see the results in the Results Viewer window: 2) Analyses for person-time data Crude Analyses The SAS code to conduct analyses, both crude and stratified, for person-time data, such as might arise in an open-cohort setting, is contained in the file epi202_person_time.sas. To begin these analyses, we have to import our data using proc import. When doing this, we create a dataset in the working directory called ‘dat’ that is used for all of our subsequent analyses. In order for proc import to work properly, we must be careful to give the correct file location (in this example, the file is stored in the folder ‘Epi 202 2018’ in my P drive) as well as the file type (here, a csv file). /*Call in data*/ proc import out= WORK.dat DATAFILE= "P:\Epi 202 2018\evans_example_data.csv"
DBMS=csv REPLACE; GETNAMES=YES; RUN; Next, we use a data step to drop observations where the exposure status is missing & to create indicators for exposed cases, unexposed cases, exposed person-time, and unexposed person-time. In this example, I will be looking at the association between hypertension (HTN) and cardiovascular disease (CHD). If you would like to use this code in a different dataset, you only need to make sure your variables (exposure, outcome, and person-time) are similarly coded (1=exposed/event; 0=unexposed/non-event) and write over the names of the variables I have used here – after that, the rest of code should work on the same. data dat; set dat; if HTN^=.; if HTN=1 and CHD=1 then exposed_case=1; if HTN=0 and CHD=1 then unexposed_case=1; if HTN=1 then exposed_PT=person_time; if HTN=0 then unexposed_PT=person_time; run; Next, we need to determine how many cases have occurred for each value of exposure and how much exposed and unexposed person-time was accumulated during follow-up. To do this, we can use the sum option in proc means and sum over the indicators we created in the previous data step. We can use the ods output command to store these sums in a new dataset called crude_open.
- Summer '14