楼主: lnlhckao123
7839 14

[问答] 请教t检验后P值小数位的保留的SAS程序 [推广有奖]

  • 0关注
  • 3粉丝

副教授

62%

还不是VIP/贵宾

-

威望
0
论坛币
14810 个
通用积分
10.6125
学术水平
7 点
热心指数
4 点
信用等级
4 点
经验
12566 点
帖子
754
精华
0
在线时间
405 小时
注册时间
2010-8-21
最后登录
2025-6-7

楼主
lnlhckao123 发表于 2011-6-21 03:23:41 |AI写论文
150论坛币
请问我的如下程序,怎样控制最后输出P值的小数位,如保留8位,12位,22位等,谢谢高手指点!
data ex3_7;                                          
  input x @@;
  if _n_<21 then c=1;
            else c=2;
cards;
-0.70 -5.60 2.00 2.80 0.70 3.50 4.00 5.80 7.10 -0.50
2.50 -1.60 1.70 3.00 0.40 4.50 4.60 2.50 6.00 -1.40
3.70  6.50 5.00 5.20 0.80 0.20 0.60 3.40 6.60 -1.10
6.00  3.80 2.00 1.60 2.00 2.20 1.20 3.10 1.70 -2.00
;
proc ttest;
var x;
class c;
run;

最佳答案

bobguy 查看完整内容

Excuting the following program will change the default format pvalue6.4 to a desired pvalue format. In the example below, it will keep 5 decimal digits %let digits=5; proc template; define column Common.pValue; notes "Default p-value column"; just = r; format = pvalue%eval(&digits+2).&digits; end; run;
关键词:sas程序 t检验 Input Data 高手指点 请教 程序 检验 SAS 小数

本帖被以下文库推荐

即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

沙发
bobguy 发表于 2011-6-21 03:23:42
Excuting the following program will change the default format pvalue6.4 to a desired pvalue format. In the example below, it will keep 5 decimal digits


%let
digits=5;
proc template;
define column Common.pValue;
notes "Default p-value column";
just = r;
format = pvalue
%eval(&digits+2).&digits;
end;
run;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
lnlhckao123 + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

藤椅
情迷仲夏夜 发表于 2011-6-21 04:01:43
为何要保留这么精确?有何统计学意义?

板凳
lnlhckao123 发表于 2011-6-21 21:03:58
你好情迷仲夏夜!我之所以要保留这么多位小数,是因为有时SAS运算后所得P值只是说小于某某值,而没说是多少,这时我想通过多保留小数位,来了解P值里小数点后非零的数字是什么,这个非零数字前有多少个零。谢谢!
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

报纸
lnlhckao123 发表于 2011-6-21 21:14:14
谢谢bobguy!可否请高手解释一下3楼所写程序的每一行的意思。还有可否请高手把3楼的程序和我在1楼的程序连接起来,我好依葫芦画瓢,看着结果窗口所出现的结果,我好慢慢琢磨,理解。谢谢指导!
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

地板
lnlhckao123 发表于 2011-6-21 22:05:09
我现在可以把1楼和3楼的程序结合起来,不过我还是不理解3楼里程序的每行具体意思。还望高手指点!我合并后的程序如下:
data ex3_7;                                                         /*independent sample ttest*/
  input x @@;
  if _n_<21 then c=1;
            else c=2;
cards;
-0.70 -5.60 2.00 2.80 0.70 3.50 4.00 5.80 7.10 -0.50
2.50 -1.60 1.70 3.00 0.40 4.50 4.60 2.50 6.00 -1.40
3.70  6.50 5.00 5.20 0.80 0.20 0.60 3.40 6.60 -1.10
6.00  3.80 2.00 1.60 2.00 2.20 1.20 3.10 1.70 -2.00
;
%let digits=6;
proc template;
define column Common.pValue;
notes "Default p-value column";
just = r;
format = pvalue%eval(&digits+2).&digits;
end;
run;
proc ttest;
var x;
class c;
run;
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

7
lnlhckao123 发表于 2011-6-22 01:45:42
可有高手指点一下,2楼程序的每行意思是什么。谢谢!!
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

8
lnlhckao123 发表于 2011-6-22 03:13:20
你好bobguy!我之前用6楼里的程序运行很好!现在怎么出错了,错误信息如下,望指导,谢谢!
104  data ex3_7;                                                  /*independent sample ttest*/
105    input x @@;
106    if _n_<21 then c=1;
107              else c=2;
108  cards;

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.EX3_7 has 40 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


113  ;
114
115  %let digits=6;
116  proc template;
117  define column Common.pValue;
118  notes "Default p-value column";
119  just = r;
120  format = pvalue%eval(&digits+2).&digits;
121  end;
NOTE: Overwriting existing template/link: Common.pValue
NOTE: COLUMN 'Common.pValue' has been saved to: SASUSER.TEMPLAT
122  run;
ERROR:  Read Access Violation In Task [ TEMPLATE ]
Exception occurred at (66F4A97B)
Task Traceback
Address   Frame     (DBGHELP API Version 4.0 rev 5)
66F4A97B  0802F50C  sasods:mcn_main+0x4997B
66F579B9  0802F7E4  sasods:mcn_main+0x569B9
66F45E7A  0802FB3C  sasods:mcn_main+0x44E7A
58E759B7  0802FF8C  sastempl:mcn_main+0x49B7
015F27C8  0802FFA0  sashost:Main+0xC204
016DD038  0802FFB4  sashost:Main+0xF6A74
7C80B729  0802FFEC  kernel32:GetModuleFileNameA+0x1BA

ERROR:  Read Access Violation In Task [ TEMPLATE ]
Exception occurred at (66F4A97B)
NOTE: PROCEDURE TEMPLATE used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds

NOTE: The SAS System stopped processing this step because of errors.
123
124


125  proc ttest;
126   var x;
127   class c;
128  run;

ERROR:  Read Access Violation In Task [ TTEST ]
Exception occurred at (66F4A673)
Task Traceback
Address   Frame     (DBGHELP API Version 4.0 rev 5)
66F4A673  0802FA54  sasods:mcn_main+0x49673
66F4A52F  0802FAEC  sasods:mcn_main+0x4952F
3F83ABC8  0802FBA4  sasttest:mcn_main+0x9BC8
3F831083  0802FF8C  sasttest:mcn_main+0x83
015F27C8  0802FFA0  sashost:Main+0xC204
016DD038  0802FFB4  sashost:Main+0xF6A74
7C80B729  0802FFEC  kernel32:GetModuleFileNameA+0x1BA

NOTE: The SAS System stopped processing this step because of errors.
ERROR:  Read Access Violation In Task [ TTEST ]
Exception occurred at (66F4A97B)
NOTE: PROCEDURE TTEST used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


而无论怎么运行,output窗口里只有
The SAS System                             03:04 Monday, June 22, 2009   1
                                                          The FREQ Procedure
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

9
lnlhckao123 发表于 2011-6-22 03:22:14
最重要的是现在我无论运行其它的什么样程序,在结尾总会出现类似如下的内容(log窗口),并且不能直接关掉SAS,而必须在任务管理器里关掉,这是怎么回事?有什么解决办法没?谢谢高手指点!
ERROR:  Read Access Violation In Task [ TTEST ]
Exception occurred at (66F4A673)
Task Traceback
Address   Frame     (DBGHELP API Version 4.0 rev 5)
66F4A673  0802FA54  sasods:mcn_main+0x49673
66F4A52F  0802FAEC  sasods:mcn_main+0x4952F
3F83ABC8  0802FBA4  sasttest:mcn_main+0x9BC8
3F831083  0802FF8C  sasttest:mcn_main+0x83
015F27C8  0802FFA0  sashost:Main+0xC204
016DD038  0802FFB4  sashost:Main+0xF6A74
7C80B729  0802FFEC  kernel32:GetModuleFileNameA+0x1BA

NOTE: The SAS System stopped processing this step because of errors.
ERROR:  Read Access Violation In Task [ TTEST ]
Exception occurred at (66F4A97B)
NOTE: PROCEDURE TTEST used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

10
lnlhckao123 发表于 2011-6-22 03:31:36
谢谢各位,我把电脑重启后,原来可以运行的程序现在也可以运行了。我发现在2楼的程序里,好像不加“notes "Default p-value column";”结果也一样,请问“notes "Default p-value column";”的作用是什么?还有,“just = r; ”是什么意思?谢谢高手指点!
即使在人大经济论坛这个网络世界,我仍以真诚为基础与我的好友进行交往!

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-23 06:04