2013年3月7日

【SAS NOTE】年累计

摘要: 1 data a; 2 input date num; 3 datalines; 4 201201 1 5 201202 2 6 201203 3 7 201301 4 8 201302 5 9 ;10 run;11 data b;12 set a;13 c=substr(put(date,$6.),1,4);14 run;15 proc print data=b;16 run;17 data c;18 set a;19 retain;20 y=substr(put(date,$6.),1,4);21 m=substr(put(... 阅读全文

posted @ 2013-03-07 14:50 colipso 阅读(237) 评论(0) 推荐(0)

【SAS NOTE】数字字符互换

摘要: 1 data a; 2 input date; 3 datalines; 4 201201 5 201202 6 201203 7 ; 8 run; 9 data b;10 set a;11 c=substr(put(date,$6.),1,4);12 run;13 proc print data=b;14 run;put()函数可以将变量转化为指定类型,不限于数字转字符。substr函数取出字符中指定位置的字符。见上一篇笔记。 阅读全文

posted @ 2013-03-07 09:02 colipso 阅读(1230) 评论(0) 推荐(0)

【SAS NOTE】substr函数

摘要: Fromhttp://blog.sina.com.cn/s/blog_6e0a03730100mwvy.htmlSubstr(s,p,n)函数【功能】字符替换与提取字符【类别】 字符函数【语法】1 (right of =) Function,提取字符:Substr(s,p,n)从字符串s中的第p个字符开始提取n个字符的子串。2 (left of =) Function,字符替换:Substr(s,p,n)=characters-to-replace,从变量s的p个字符开始替换n个字符【注意】:1.必须是从字符变量中提取,对数值变量不起作用,必须转换为字符变量,如果是数字变量,在调用substr 阅读全文

posted @ 2013-03-07 08:51 colipso 阅读(1152) 评论(0) 推荐(0)

导航