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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.