SAS中的PROC GENMOD预测变量的无效参考值和无有效观测值

时间:2017-12-11 20:19:49

标签: sas sas-studio

我试图对二元预测变量(c1kdscc3,c1kdscc4和c1kdscc5)建模二元结果(p1ODD)。当我尝试执行PROC GENMOD时,我的日志表明我的c1kdscc3参考值无效。它还告诉我,由于响应变量中的响应无效,因此没有有效的观察结果,尽管我的代码中已经定义了所有内容。

以下是PROC GENMOD部分之前出现的有问题的代码:

PROC FORMAT;
Value c1kdscc_binfmt 
0 = "[3,4,5] Often or more (Ref)" 
1 = "[1,2] Never/Seldom"; 
Value p1ODD_binfmt 
0 = "Negative (Ref)"
1 = "Positive";
RUN;


TITLE "Logistic Regression Using PROC GENMOD";
PROC GENMOD DATA=MY;
CLASS c1kdscc3 (REF= "Often or more (Ref)") / PARAM = ref;
MODEL p1ODD = c1kdscc3 / DIST= binomial LINK=log SCALE=1;
RUN; QUIT; 

有人知道我是否应该修复我如何定义c1kdscc3到c1kdscc5的参考值以及如何最好地重写我的响应变量以在PROC GENMOD中工作?

Sample Data: 
    Age     p1ODD       c1kdscc3    clkdscc4    clkdscc5
    12      Positive    Very Often  Always      Always
    16      Positive    Seldom     Quite Often  Seldom
    14      Negative    Very Often  Always      Seldom
    17      Negative    Quite Often Seldom      Very Often
    13      Negative    Quite Often Quite Often Seldom
    17      Negative    Quite Often Quite Often Never

记录和错误消息:

172        /*Analysis using GENMOD*/
 173        
 174        
 175        TITLE "Logistic Regression Using Proc GENMOD";
 176        PROC GENMOD DATA=MY;
 177        CLASS c1kdscc3 (REF= "Often or more (Ref)") / PARAM = ref;
 178        MODEL p1ODD = c1kdscc3 / DIST= binomial LINK=log SCALE=1;
 179        RUN;


 ERROR: Invalid reference value for c1kdscc3.
 ERROR: No valid observations due to invalid or missing values in the response, explanatory, offset, frequency, or weight variable.
 NOTE: The SAS System stopped processing this step because of errors.

谢谢!

1 个答案:

答案 0 :(得分:0)

这是您在PROC FORMAT中的格式化值与您在CLASS语句中指定的导致问题的值之间的不匹配。我可以使用下面的代码复制问题和错误。

通过更改:

来修复它
CLASS c1kdscc3 (REF= "Often or more (Ref)") / PARAM = ref;

符合您的格式:

0 = "[3,4,5] Often or more (Ref)" 

所以最终的代码应该是这样的:

CLASS c1kdscc3 (REF= "[3,4,5] Often or more (Ref)") / PARAM = ref;

如果需要,可以复制问题的代码,请注意我必须这样做,因为我们无法运行您的代码:

proc format ;
value $ myBrand_fmt
'ice1' = 'Ice #1'
'ice2' = 'Ice #2'
'ice3' = 'Ice #3';
run;

data Icecream;
   input count brand$ taste$;
   datalines;
70  ice1 vg
71  ice1 g
151 ice1 m
30  ice1 b
46  ice1 vb
20  ice2 vg
36  ice2 g
130 ice2 m
74  ice2 b
70  ice2 vb
50  ice3 vg
55  ice3 g
140 ice3 m
52  ice3 b
50  ice3 vb
;

proc genmod data=Icecream rorder=data;
   freq count;
   class brand (ref='#1');
   format brand $mybrand_fmt.;
   model taste = brand / dist=multinomial
                         link=cumlogit
                         aggregate=brand
                         type1;

run;

您还遇到的问题是,您的数据似乎与指定的格式不符,因此我不确定该怎么说。

您已指定格式定义但未应用它们,并且您的数据似乎与您的格式定义不一致。但是,这个问题比单个答案或问题中的答案更多。您可能需要备份几个步骤,并了解如何首先正确设置数据并使用格式,然后继续进行GENMOD过程。