I am doing logistic regression using all categorical variables. When I create a 2x2 table of the outcome (casehyst_path) and the exposure (jointyears_cat), each level of jointyears_cat (0, 1, 2 and 3) all show up. But when I run the logistic regression, it ignores 0, and uses 1 as the reference, even though I specified ref=first. Here is my code, and I've attached screenshots of my results. Any help is appreciated! Thanks.
data work.adeno1;
set work.adenovar;
if jointyears = 0 or hash = 2 then jointyears_cat = "0";
if 0 LT jointyears LE 2 then jointyears_cat = "1";
if 2 LT jointyears LE 5 then jointyears_cat = "2";
else if jointyears GT 5 then jointyears_cat = "3";
data work.adenovar;
set work.adeno1;
if 20 LE refage LE 34 then refagecat = "0";
if 35 LE refage LE 39 then refagecat = "1";
if 40 LE refage LE 44 then refagecat = "2";
if 45 LE refage LE 49 then refagecat = "3";
if 50 LE refage LE 54 then refagecat = "4";
else if 55 LE refage LE 59 then refagecat = "5";
if 36 LE hashlage1 LE 60 then before35 = "0";
else if 3 LE hashlage1 LE 35 then before35 = "1";
if 36 LE hashlage2 LE 60 then before35 = "0";
else if 3 LE hashlage2 LE 35 then before35 = "1";
if 36 LE hashlage3 LE 60 then before35 = "0";
else if 3 LE hashlage3 LE 35 then before35 = "1";
if 36 LE hashlage4 LE 60 then before35 = "0";
else if 3 LE hashlage4 LE 35 then before35 = "1";
proc freq data = work.adenovar;
where before35 = "1";
tables jointyears_cat*casehyst_path / norow nopercent;
run;
title "hysterectomy controls age";
proc logistic data = adenovar descending;
where before35 = "1";
class jointyears_cat refagecat / param = ref ref = first;
model casehyst_path = jointyears_cat refagecat;
run;
Run a Proc freq on your categorical variable of interest with the same "where before35="1" ".
If you don't have any 0 where before35='1' then that is the issue: no qualifying data.
Run a Proc freq on your categorical variable of interest with the same "where before35="1" ".
If you don't have any 0 where before35='1' then that is the issue: no qualifying data.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.