Hi,
When can we use class statement? If I have a binary variable and using Proc Logistic, should I use class statement for that variable?
Thanks
It's true that you can and should use Class statement for binary variables, but its not a requirement.
The CLASS statement is used to declare categorical (as opposed to interval/continuous) predictor variables. Generally nominal variables (males/female, yes/no, event/nonevent) are treated as categorical.
Any predictor variables that have type=character must be declared as class variables or you will get an error.
Hope this helps.
Ray
Hi Ray,
Thanks for the response. Below are three different codes and I need guidance:
proc logistic data=pe.matchedata_21;
strata group;
class CMV_ca_2_1 (ref='2');
model PEstatus (event='1')= CMV_ca_2_1;
run;
proc logistic data=pe.matchedata_21;
strata group;
class CMV_ca_2_1 (ref='1');
model PEstatus (event='1')= CMV_ca_2_1;
run;
proc logistic data=pe.matchedata_21;
strata group;
model PEstatus (event='1')= CMV_ca_2_1;
run;
Thanks
Use code #2 where you get what you want without having to rely on obscure default rules. That explicit coding will also be much easier to interpret 6 months from now.
In general you'll also want to specify your parameterization method. I don't know if it matters for 0/1 coding, but as suggested before, being explicit doesn't hurt. And defaults can change between versions of SAS so it's good to be explicit.
proc logistic data=pe.matchedata_21;
strata group;
class CMV_ca_2_1 (ref='1') / param=ref;
model PEstatus (event='1') = CMV_ca_2_1;
run;
Thanks PGStats and Reeza!
I wanted an expert endorsement to my understanding which I got. Just to reconfirm, this is true even for a binary variable to use the class statement with explicit reference indication.
Regards
It's true that you can and should use Class statement for binary variables, but its not a requirement.
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.