全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1293 4
2019-01-21
文件第一个变量比较麻烦,不知道该怎么读入。
Data A1(label="万科A");
Infile 'M:\000157.txt' delimiter = '09'x  Missover Dsd lrecl=32767 firstobs=3 ;
Format date yymmdd10.;
format time time5.;
Format OpPr COMMA19.2;
Format HiPr COMMA19.2;
Format LoPr COMMA19.2;
Format ClPr COMMA19.2;
Format TrdVol 21.2;
Informat date yymmdd10.;
informat time time5.;
Informat OpPr COMMA19.2;
Informat HiPr COMMA19.2;
Informat LoPr COMMA19.2;
Informat ClPr COMMA19.2;
Informat TrdVol 21.2;
Label date="交易日期";
Label OpPr="开盘价";
Label HiPr="最高价";
Label LoPr="最低价";
Label ClPr="收盘价";
Label TrdVol="成交量";
Input
date time OpPr  HiPr  LoPr  ClPr  TrdVol ;
Run;
这个读入的时间总是不对。


附件列表

000157.txt

大小:443.09 KB

 马上下载

二维码

扫码加我 拉你入群

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

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

全部回复
2019-1-22 03:33:52
You do better post 10 line of the data from your txt file since the site will ask 1$ to download the txt file to help you out.
二维码

扫码加我 拉你入群

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

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

2019-1-22 08:42:17
Newkoarla 发表于 2019-1-22 03:33
You do better post 10 line of the data from your txt file since the site will ask 1$ to download the ...
时间        开盘        最高        最低        收盘             成交量   

2018/07/09-14:05        3.82        3.82        3.81        3.81             205800   
2018/07/09-14:10        3.82        3.82        3.81        3.82             144600   
2018/07/09-14:15        3.82        3.83        3.81        3.83             637800   
2018/07/09-14:20        3.83        3.83        3.82        3.82             168700   
2018/07/09-14:25        3.82        3.83        3.82        3.82             165300   
2018/07/09-14:30        3.82        3.83        3.82        3.82              87300   
2018/07/09-14:35        3.82        3.83        3.81        3.81             387900   
2018/07/09-14:40        3.81        3.82        3.81        3.81             319600   
2018/07/09-14:45        3.81        3.82        3.81        3.82             497300   
2018/07/09-14:50        3.81        3.83        3.81        3.83             736100   
2018/07/09-14:55        3.82        3.83        3.82        3.83            1504500        
二维码

扫码加我 拉你入群

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

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

2019-1-25 04:56:27
Great, so basically the problem you have is the wrong INFORMAT for the datetime field, and there is no Date or Time field in the TEXT file, it is the whole DateTime,  get to use function *part() to separate the date and time, so you can refer below code and let me know if you still have problem.


data stockDataFile(drop=exDatetime);
Label         TrsDate="交易日期"
                TrsTime="交易Time"
                OpPr="开盘价"
                HiPr="最高价"
                LoPr="最低价"
                ClPr="收盘价"
                TrdVol="成交量";
attrib exDatetime informat=ANYDTDTM19. format=datetime19.
                TrsDate informat=date10. format=yymmdd10.
                TrsTime informat=time8. format=time8.;

infile "/folders/myfolders/RangTech/stockdata.txt" dlm='09'x dsd lrecl=32767 missover; /*change the file path*/
input        exDatetime
                OpPr
                HiPr
                LoPr
                ClPr
                TrdVol;
TrsDate = datepart(exDatetime);
TrsTime = timepart(exDatetime);
;
run;
二维码

扫码加我 拉你入群

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

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

2019-2-12 14:26:08
Newkoarla 发表于 2019-1-25 04:56
Great, so basically the problem you have is the wrong INFORMAT for the datetime field, and there is  ...
Thank you very much!
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群