楼主: wx2123
1091 8

[问答] 如何存储SAS回归产生的系数? [推广有奖]

  • 1关注
  • 2粉丝

硕士生

70%

还不是VIP/贵宾

-

威望
0
论坛币
5595 个
通用积分
220.6077
学术水平
1 点
热心指数
5 点
信用等级
0 点
经验
3111 点
帖子
93
精华
0
在线时间
193 小时
注册时间
2015-9-10
最后登录
2025-11-9

楼主
wx2123 在职认证  发表于 2022-10-17 23:53:14 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币


请教各位:

我用SAS proc genmod跑了一个回归,得到了下面的结果:

SAS


需要完成下面两步

1. 把回归的系数(3.6295, 5.0238, 3.3486)存到一个文件里(Excel或者txt都行)

2. 把存储的系数读进来。


这个应该怎么写SAS程序呢?而且我有很多个回归的结果,都需要存下来。

下面是我写的代码。

  1. data nor;
  2. input x y;
  3. datalines;
  4. 0 5
  5. 0 7
  6. 0 9
  7. 1 7
  8. 1 10
  9. 1 8
  10. 2 11
  11. 2 9
  12. 3 16
  13. 3 13
  14. 3 14
  15. 4 25
  16. 4 24
  17. 5 34
  18. 5 32
  19. 5 30
  20. ;

  21. proc genmod data=nor;
  22. model y = x / dist = normal
  23.        link = identity;
  24. run;
复制代码


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Identity genmod normal entity Identi

沙发
橙红的果士 学生认证  发表于 2022-10-18 11:12:41
用 ods trace on 跟踪跑出来的表名,再通过ods output 把表导出就行

藤椅
learsaas 发表于 2022-10-18 16:16:31
橙红的果士 发表于 2022-10-18 11:12
用 ods trace on 跟踪跑出来的表名,再通过ods output 把表导出就行
  1. ods output ParameterEstimates=result;
  2. proc genmod data=nor;
  3. model y = x / dist = normal
  4.        link = identity ;
  5. run;
  6. ods output close;
复制代码


板凳
whymath 发表于 2022-10-18 21:31:38
另一种做法,利用 code 语句:如果有模型要运行较高的次数,使用该语句能带来明显的输出速度的提升。
2.png

查看我的精华帖:免费的 SAS 软件

报纸
wx2123 在职认证  发表于 2022-10-18 22:41:27
非常感谢,我先试试看。有问题再来请教!

地板
wx2123 在职认证  发表于 2022-10-19 03:42:02
learsaas 发表于 2022-10-18 16:16
感谢答复。
我试了你说的方法,现在可以输出一个回归的系数。

下一步是如何存储多个回归的系数。
下面这个例子,有result 和result2两个输出的数据集。怎么才能把他们合起来呢?
  1. ods output ParameterEstimates=result;
  2. proc genmod data=nor;
  3.         model y = x / dist = normal
  4.                               link = identity
  5.                                         ;
  6. run;
  7. ods output close;

  8. ods output ParameterEstimates=result2;
  9. data nor2;
  10. set nor;
  11. log_x = log(x);
  12. run;

  13. proc genmod data=nor2;
  14.         model y = log_x / dist = normal
  15.                                   link = identity
  16.                                         ;       
  17. run;

  18. ods output close;
复制代码

7
wx2123 在职认证  发表于 2022-10-19 03:46:56
whymath 发表于 2022-10-18 21:31
另一种做法,利用 code 语句:如果有模型要运行较高的次数,使用该语句能带来明显的输出速度的提升。
你的意思就是自己写一段代码(test.sas),插入proc genmod里面,是吧?
你这个test.sas文件应该是在做预测吧?

8
whymath 发表于 2022-10-19 21:55:54
wx2123 发表于 2022-10-19 03:46
你的意思就是自己写一段代码(test.sas),插入proc genmod里面,是吧?
你这个test.sas文件应该是在做预测 ...
文件“test.sas”是程序语句生成的,并非手动撰写的。
在proc genmod过程步中使用code语句可以将模型的参数估计结果存储到一个代码文件中,该文件甚至可以用于后续的数据预测。
用例见:https://support.sas.com/document ... ntrocom_sect013.htm

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

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