全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
5933 3
2013-01-24
求助日期存贮方式是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.


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

扫码加我 拉你入群

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

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

全部回复
2013-1-24 16:40:06
在原来的数据集中的data步中用format试试,如果在过程步中用format仍然不会改变原来数据集中的输出格式。
或者产生一个新变量newd=put(date, date9.);
宏的问题不太懂,不知是否可行。求解答。。。。。。。
二维码

扫码加我 拉你入群

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

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

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;
二维码

扫码加我 拉你入群

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

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

2013-1-24 17:40:32
带"XXX"d 的这种格式 只适合date格式的。月份要用简写三个英文字母表示。
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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