Programming the statistical procedures from SAS

How do I bring a format into a model statement?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

How do I bring a format into a model statement?

Hello community,

I would like to know how I could bring in the following formats for the variable "ATTRACTL" into my model output, so that the labels indicated by the formats can be seen in the model output...

"bothstatusNew" is a four level variable, I'm attempting simple multinomial regression with this code.

Or is it easiest to change the numeric level coding into character form coding using a data step and length statement for the predictor variable?

Thank you. Here I provide an example code:

Data psw.NewVar6;

  set psw.NewVar5;

proc format;

value ATTRACTL

0 = 'Only Male'

1='Male and Female'

2= 'Only Female'

3= 'None'

;

run;

proc freq Data=psw.NewVar6;

tables ATTRACTL;

format ATTRACTL ATTRACTL.;

run;

proc logistic data = psw.NewVar6;

class ATTRACTL;

model bothstatusNEW = ATTRACTL;

run;


Accepted Solutions
Solution
‎05-14-2015 08:24 AM
Occasional Contributor
Posts: 13

Re: How do I bring a format into a model statement?

Sorry forgot to add bothstatusNEW to the class statement in the model code. This is the correction:

proc logistic data = psw.NewVar6;

class bothstatusNEW ATTRACTL;

model bothstatusNEW = ATTRACTL;

run;

View solution in original post


All Replies
Solution
‎05-14-2015 08:24 AM
Occasional Contributor
Posts: 13

Re: How do I bring a format into a model statement?

Sorry forgot to add bothstatusNEW to the class statement in the model code. This is the correction:

proc logistic data = psw.NewVar6;

class bothstatusNEW ATTRACTL;

model bothstatusNEW = ATTRACTL;

run;

Grand Advisor
Posts: 10,029

Re: How do I bring a format into a model statement?

Add the same format statement to the proc logistic code.

Format is one of those statements that are available in almost every proc that displays or manipulates data without an explicit entry in the syntax.

A big advantage to the format approach is that if you want to see the results for a different grouping of values is to create a new format and apply that in the code instead of having to go back to a data step and add a new variable.

Such as:

proc format;

value ATTRACTLALt

0,2 = 'Only Male or Only Female'

1='Male and Female'

3= 'None'

;

run;

Occasional Contributor
Posts: 13

Re: How do I bring a format into a model statement?

So do I place my format code within the model statement before the run command and after the model statement for example?

Occasional Contributor
Posts: 13

Re: How do I bring a format into a model statement?

Scratch that, thank you Ballard I believe I understand what your are saying thank you for your response!!!

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 233 views
  • 3 likes
  • 2 in conversation