我希望能够以这种方式转换整列日期。例如,2017年1月1日至2017年1月1日。我意识到这是一个令人费解的方式,但我不完全确定我会如何处理这种逻辑。此外,是否碰巧有这样的SAS格式?谢谢。将mm/dd/yy转换为月份名称DayNumber,YearNumber in SAS
-1
A
回答
0
确实有一种可以使用的格式。下面是一个样例使用的测试数据:
data test;
input datestring $;
datalines;
01/01/2017
;
run;
使用输入的字符串值转换为SAS日期,然后将函数用于创建一个字符变量抱着你正在寻找的表示:
data test2;
set test;
date_as_date = input(datestring,ddmmyy10.);
date_formatted = put(date_as_date,worddate20.);
run;
数字20用于描述长度足以保存完整值的长度,使用较低的数字可能会导致截断,例如
date_formatted = put(date_as_date,worddate3.);
put date_formatted=;
dateformatted=Jan
0
在某些情况下,需要的日期格式可能不存在(在这种情况下,它确实“worddate20。”),但作为一个例子...
你既可以写一个函数式宏将SAS日期转换为“姓氏+日,年”格式,例如
%MACRO FULLMDY(DT) ; catx(', ',catx(' ',put(&DT,monname.),put(&DT,day.)),put(&DT,year4.)) %MEND ; data example1 ; dt = '26jul2017'd ; fulldate = %FULLMDY(dt) ; run ;
或者,您可以构建自定义格式,覆盖数据中可能存在的所有日期,例如,
data alldates ; retain fmtname 'FULLMDY' type 'N' ; do dt = '01jan1900'd to '01jan2100'd ; mdy = catx(', ',catx(' ',put(dt,monname.),put(dt,day.)),put(dt,year4.)) ; output ; end ; rename dt = start mdy = label ; run ; proc format cntlin=alldates ; run ; data example2 ; dt = '26jul2017'd ; format dt fullmdy. ; run ;
相关问题
- 1. 将月份名称转换为数字
- 2. 使用sql将月份编号转换为月份名称
- 3. 如何将月份数字转换为月份短名称?
- 4. 将月份int转换为月份名称
- 5. 使用JavaScript将月份名称转换为月份编号
- 6. 将月份名称转换为SQL Server中的月份编号
- 7. 将月份编号转换为月份名称
- 8. 如何将月份名称转换为数字?
- 9. 如何将月份名称转换为月份在Ruby中整数?
- 10. 如何将数字月份数字转换为使用PHP的月份名称
- 11. 如何在Oracle中将月份数字转换为完整的月份名称?
- 12. 简单的方法将月份名称转换为月份编号在php
- 13. 如何将月份从unix时间戳从数字转换为月份名称?
- 14. PHP:将本地月份名转换为月份号
- 15. 使用Carbon将月份名称转换为字符串编号?
- 16. 将熊猫线图转换为月份名称的条形图
- 17. 如何将特定的字符串转换为月份名称
- 18. 如何将时间戳值转换为月份名称
- 19. 在python中将名称月份转换为数字
- 20. 如何将月份名称转换为int?
- 21. 在Oracle中将希伯来语月份名称转换为英文月份名称
- 22. 如何将月份转换为java中的年份和月份
- 23. SAS格式:完整的月份名称为整数
- 24. 将月份名称更改为SSIS中的月份编号
- 25. 跳过缩写月份名称为月
- 26. 转换为日期时间和提取月份名称
- 27. DateTime从C#中的int转换为月份名称,Silverlight
- 28. 月份名称2008
- 29. 转换月份数月的短名
- 30. 转换日期到月份名称和年份
将来请显示您尝试过的内容。正如发布的这个问题不符合SO规则 – Reeza