BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tpham
Quartz | Level 8

I am running Proc Logistic. is there a way to run the class statement by putting the value instead of the format name? So in order to get my command to work I had to run the following:

proc logistic data = recode ;

  class agegp (ref='2.age grp 45-65') sex (ref='1.Male') /param = ref;

  model Y (event='1. <64') = agegp sex;

run;

So in this case, agegroup=2  and sex=1 are my reference groups (my format is value.category). I have tried doing the following:

proc logistic data = recode ;

  class agegp (ref=2) sex (ref=1) /param = ref;

   model Y (event=1) = agegp sex;

run;

The code above gives me a syntax error. I am hoping to avoid copying and pasting the format names. And hopefully make my code shorter.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Add a FORMAT statement to the PROC to clear the assigned formats from the variables.

proc logistic data = recode ;

  format agegp sex ;

  class agegp (ref=2) sex (ref=1) /param = ref;

  model Y (event=1) = agegp sex;

run;

View solution in original post

6 REPLIES 6
SteveDenham
Jade | Level 19

If a format is assigned to the variable, the ref= syntax requires the use of the formatted value.  See The Logistic Procedure>Syntax>CLASS Statement>REF= for the word on this.

Steve Denham

Tom
Super User Tom
Super User

Add a FORMAT statement to the PROC to clear the assigned formats from the variables.

proc logistic data = recode ;

  format agegp sex ;

  class agegp (ref=2) sex (ref=1) /param = ref;

  model Y (event=1) = agegp sex;

run;

SteveDenham
Jade | Level 19

Sweet!  I didn't know you could clear formats like that.

Steve Denham

Tpham
Quartz | Level 8

Thanks! I this works... but is there a way to have the best of both worlds.. not having to type in the format in the class statement AND have it output with formats?

Tom
Super User Tom
Super User

Go to work for SAS and re-write PROC LOGISTIC?

The default reference is the largest value (unless you add the DESCENDING option).

So code your formats so that the reference value is the largest value.

Reeza
Super User

Or smallest and use ref=first

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 15066 views
  • 0 likes
  • 4 in conversation