【发布时间】:2017-04-14 05:09:14
【问题描述】:
我有字符日期变量,我需要将其转换为数字日期变量。我的字符日期变量的格式为monyy7. 格式。
请建议我如何将其转换为 monyy7 格式的数字。
【问题讨论】:
标签: sas
我有字符日期变量,我需要将其转换为数字日期变量。我的字符日期变量的格式为monyy7. 格式。
请建议我如何将其转换为 monyy7 格式的数字。
【问题讨论】:
标签: sas
使用INPUT函数可以得到想要的结果:
data a;
input date_char $7.;
cards;
jun2015
apr1914
feb2010
;
run;
data a1;
set a;
format date monyy7.;
date = input(date_char,monyy7.);
run;
【讨论】:
你应该把它写成to_number(to_char(your_date_variable,'dd'),'99')。
和示例查询:
日期select to_number(to_char(sysdate,'dd'),'99') from dual
一个月select to_number(to_char(sysdate,'mm'),'99') from dual
年份select to_number(to_char(sysdate,'rrrr'),'9999') from dual
【讨论】: