Comparison of paired count data between two treatment periods with different length of follow-up

I am currently using SAS 9.4 to carry out a retrospective analysis of patients who switched from drug A to drug B. I am interested in assessing the hospitalization counts before and after switch to drug B. Baseline drug A treatment was for 3 months, and follow-up time on drug B was for 1 year. The patient cohort served as their own comparator group. How do I account for the differences in treatment periods (3 months of drug A vs 1 year of drug B) when comparing incidence rates using Poisson GLMM models? Is there a way I could account for the differences in time periods in the model? Is there another way I could compare the incidence rates?

You should use $$\log(\text{exposure time)$$ as an offset in the (log link) poisson regression. That way you are comparing rates and not expected counts. For details see How is a Poisson rate regression equal to a Poisson regression with corresponding offset term? (and its links and references.) You do this the same way with a random effects model (I suppose you plan to include patient-level random intercepts?) and for a pure glm with only fixed effects.