楼主: 艾北
5965 3

sas中日期的读取问题 [推广有奖]

  • 0关注
  • 0粉丝

初中生

71%

还不是VIP/贵宾

-

威望
0
论坛币
65 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
434 点
帖子
15
精华
0
在线时间
12 小时
注册时间
2010-9-15
最后登录
2013-1-28

楼主
艾北 发表于 2013-1-24 16:30:52 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
求助日期存贮方式是12OCT2012时,我用了下面红色字体这种方式读取是可以的。
  data temp_day&i.;
  set or.vp_op_np_pack;
  where cal_date="&&cal_date&i."d;
  run;

但现在遇到这种方式存贮的日期20121015,尝试了以下几种方式读取都不行;
cal_date="&&cal_date&i."d;
ERROR: Invalid date/time/datetime constant "20121015"d.
ERROR: Syntax error while parsing WHERE clause.



cal_date="&&cal_date&i.";
ERROR: WHERE clause operator requires compatible variables.


cal_date=&&cal_date&i.
ERROR: Some character data was lost during transcoding in the dataset WORK.TEMP_DAY1. Either the data
       contains characters that are not representable in the new encoding or truncation occurred
       during transcoding.


然后想把日期换成最开始那种存贮方式,我查到说这种格式叫DATE9. 然后用了format如下,但还是不行。
format cal_date DATE9.;
ERROR: Some character data was lost during transcoding in the dataset WORK.TEMP_DAY2. Either the data
       contains characters that are not representable in the new encoding or truncation occurred
       during transcoding.


求指教,非常感谢!
二维码

扫码加我 拉你入群

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

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

关键词:Characters truncation compatible Character represent compatible error ERROR where

沙发
henryyhl 发表于 2013-1-24 16:40:06
在原来的数据集中的data步中用format试试,如果在过程步中用format仍然不会改变原来数据集中的输出格式。
或者产生一个新变量newd=put(date, date9.);
宏的问题不太懂,不知是否可行。求解答。。。。。。。
It's not going to be easy, but it is going to be worth it.

藤椅
pobel 在职认证  发表于 2013-1-24 16:44:35
data test;
   input date : yymmdd10.;
   put date yymmddn8.;
   cards;
2013-01-12
2013-01-13
;

%let dt=20130113;
data test1;
   set test;
   where put(date,yymmddn8.)="&dt";run;
和谐拯救危机

板凳
webgu 发表于 2013-1-24 17:40:32
带"XXX"d 的这种格式 只适合date格式的。月份要用简写三个英文字母表示。
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

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

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