请教各位了,SAS中的日期数据比如,2004-04-15,应该怎样转换为数值型的20040415?多谢了
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
***1.Use informat to read in your data, so sas can understand it is a date value.
***2.sas stores this variable x as a numeric number, this number means how many day after 1960-1-1, the day SAS company was started.
***3.But if you don't use format, it won't print out like a data value '20040415'.
***4.There is 6 different yymmdd formats can help you to print x variable:
yymmddb10. It means 'space', 2004 4 15
yymmddc10. It means 'colon', 2004:4:15
yymmddd10. It means 'hyphen', 2004-4-15 (This is default, it is the same as mmddyy10.)
yymmddn10. It means 'none' 20040415
yymmddp10. It means 'period' 2004.4.15
yymmdds10. It means 'slash' 2004/4/15
***5.You can also use other formats like: mmddyy10., mmddyy8., yymmn4., yyq4. (quarter of the year), monyy7. (Apr2004)...****;
data
input
cards
2004-4-15
1960-1-2
2005-9-1
2007-2-14
2008?5?10
2001#1#1
;
run
proc
format
1960/1/2
不用这么麻烦了
date=compress(date,'-'); date1=input(date,yymmdd10.); informat date1 yymmdd10.; format date1 yymmdd10.; drop date; rename date1=date; label date1='date';
将这段程序插进去就可以了,格式和属性都可以得到更改。