楼主: gxa1
1068 4

[问答] 2018/07/09-14:05这样格式的数据如何读入? [推广有奖]

  • 2关注
  • 0粉丝

副教授

46%

还不是VIP/贵宾

-

威望
0
论坛币
416 个
通用积分
8.5500
学术水平
3 点
热心指数
5 点
信用等级
3 点
经验
38068 点
帖子
359
精华
0
在线时间
1312 小时
注册时间
2009-3-27
最后登录
2024-5-3

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
文件第一个变量比较麻烦,不知道该怎么读入。
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;
这个读入的时间总是不对。


二维码

扫码加我 拉你入群

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

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

关键词:delimiter informat missover informa delimit

000157.txt

443.09 KB

已有 1 人评分热心指数 收起 理由
eijuhz + 1 精彩帖子

总评分: 热心指数 + 1   查看全部评分

沙发
Newkoarla 发表于 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.

使用道具

藤椅
gxa1 发表于 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        
已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
admin_kefu + 20 + 2 + 2 + 2 热心帮助其他会员

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

使用道具

板凳
Newkoarla 发表于 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;
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
gxa1 + 1 + 4 + 4 精彩帖子

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

使用道具

报纸
gxa1 发表于 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!

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-10 12:09