楼主: 3qsir
2172 8

求助: 如何将滚动子样本分别导出至Excel档(csv) [推广有奖]

  • 2关注
  • 1粉丝

副教授

52%

还不是VIP/贵宾

-

威望
0
论坛币
13606 个
通用积分
27.0809
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
71836 点
帖子
367
精华
0
在线时间
931 小时
注册时间
2011-5-18
最后登录
2021-3-6

楼主
3qsir 发表于 2014-3-3 00:07:14 |AI写论文
10论坛币
我想要从全样本(test.file)中个别求的滚动样本数据tempfile1,tempfile2,...tempfile476,
export to out1.csv out2.csv.....out476.csv How to correct the error in the log file ?
Sincerly !
Cited by :

SAS Code Fragments

Macro to Compute a "rolling" standard deviation Log file
-------------------------------------
14         GOPTIONS ACCESSIBLE;
15         %macro rollspl;
16           %do firstobs = 1 %to 476;
17             %let lastobs = %eval( &firstobs + 24)
18          data tempfile.&firstobs;
19             set work.test(firstobs=&firstobs obs=&lastobs);
20          run;
21             proc export data=tempfile.&firstobs
22               outfile="c:\temp\out.&firstobs.csv"
23            dbms=csv
24            replace;
25            run;
26           %end;
27         %mend rollspl;
28         %rollspl
ERROR: Libname TEMPFILE is not assigned.
ERROR: Export unsuccessful.  See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE EXPORT used (Total process time):
-------------------------------------------------------------------


关键词:EXCEL xcel exce cel accessible standard correct export Excel error

沙发
yongyitian 发表于 2014-3-3 00:07:15
3qsir 发表于 2014-3-5 20:17
中间的点delete,  还是有ERROR
15         %macro rollsa;
16           %do firstobs = 1 %to 476;
  1. * line 4, 6, and 9 below were modified;
  2. %macro rollsa;
  3.    %do firstobs = 1 %to 476;
  4.       %let lastobs = %eval(&firstobs + 24);
  5.       data tempfile&firstobs;
  6.           set work.test(firstobs=&firstobs  obs=&lastobs);
  7.       run;
  8.       proc export data=tempfile&firstobs
  9.          outfile="c:\temp\out&firstobs..csv"
  10.          dbms=csv
  11.          replace;
  12.       run;
  13.   %end;
  14. %mend rollsa;
  15. %rollsa
复制代码
已有 2 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
3qsir + 5 + 5 + 5 热心帮助其他会员
Still.. + 50 热心帮助其他会员

总评分: 论坛币 + 50  学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

藤椅
nomad5 发表于 2014-3-4 14:39:24
tempfile.&firstobs out.&firstobs
中间的点

板凳
3qsir 发表于 2014-3-4 22:46:04
I will try it aftercorrect to tempfile&firstobs

Thank Sir !

报纸
irisbird 发表于 2014-3-5 06:39:59
tempfile是一个library 吗? 如果不是,显然后面不能跟一个点

地板
3qsir 发表于 2014-3-5 07:41:32
Thanks irisbird ,
It is dataset name
I had correct it yesterday.

7
3qsir 发表于 2014-3-5 20:17:04
中间的点delete,  还是有ERROR
15         %macro rollsa;
16           %do firstobs = 1 %to 476;
17                 %let lastobs = %eval(&firstobs + 24)
18                      data tempfile&firstobs;
19                  set work.test(firstobs=&firstobsobs=&lastobs);
20                 run;
21             proc export data=tempfile&firstobs
22               outfile="c:\temp\out&firstobs.csv"
23                 dbms=csv
24                   replace;
25            run;
26           %end;
27         %mend rollsa;
28         %rollsa
NOTE: Line generated by the invoked macro "ROLLSA".
28          set work.test(firstobs=&firstobs obs=&lastobs);
ERROR 180-322: Statement is not valid or it is used out of proper order.
ERROR: File WORK.TEMPFILE1.DATA does not exist.
ERROR: Export unsuccessful.  See SAS Log for details.
real time           0.05 seconds
cpu time            0.06 seconds

8
3qsir 发表于 2014-3-5 21:12:06
I try only n=1 is OK !
----------------------------------
data tempfile1;
set work.test(firstobs=1 obs=25);
run;
proc export data=tempfile1
outfile="c:\temp\out1.csv"
dbms=csv
replace;
run;

9
3qsir 发表于 2014-3-6 18:33:10
Thanks for yongyitian's help . Riun the code is OK !
I add "." and plus";" in my original codes.
已有 1 人评分论坛币 收起 理由
admin_kefu + 100 热心帮助其他会员

总评分: 论坛币 + 100   查看全部评分

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

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