Programming the statistical procedures from SAS

Proc Logistic, set reference group without using formats?

Accepted Solution Solved
Reply
Contributor
Posts: 58
Accepted Solution

Proc Logistic, set reference group without using formats?

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.


Accepted Solutions
Solution
‎10-31-2013 10:17 AM
Super User
Super User
Posts: 6,706

Re: Proc Logistic, set reference group without using formats?

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


All Replies
Respected Advisor
Posts: 2,655

Re: Proc Logistic, set reference group without using formats?

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

Solution
‎10-31-2013 10:17 AM
Super User
Super User
Posts: 6,706

Re: Proc Logistic, set reference group without using formats?

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;

Respected Advisor
Posts: 2,655

Re: Proc Logistic, set reference group without using formats?

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

Steve Denham

Contributor
Posts: 58

Re: Proc Logistic, set reference group without using formats?

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?

Super User
Super User
Posts: 6,706

Re: Proc Logistic, set reference group without using formats?

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.

Super User
Posts: 18,589

Re: Proc Logistic, set reference group without using formats?

Or smallest and use ref=first

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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