0

我正在尝试p1ODD在二进制预测变量(c1kdscc3c1kdscc4)上建模二进制结果( c1kdscc5)。当我尝试这样做时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.

谢谢!

4

1 回答 1

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 过程。

于 2017-12-12T01:27:39.767 回答