03 2013 档案

【SAS NOTES】sas对中文的支持
摘要:对sas文件的修改nls\en\SASV9.CFG81行找到/* SAS/SHARE APPLSYS macro library pathname */-SET SASSAML !sasext0\share\sasmacro\在后面加入-DBCSLANG CHINESE-DBCS-DBCSTYPE PCMS180行处找到/* Setup the SAS System load image search paths definition */-PATH (在下一行插入 "!sasext0\dbcs\sasex... 阅读全文

posted @ 2013-03-27 15:49 colipso 阅读(439) 评论(0) 推荐(0) 编辑

【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 阅读(229) 评论(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 阅读(1223) 评论(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 阅读(1092) 评论(0) 推荐(0) 编辑

【SAS NOTE】数组
摘要:本文引自:http://mengyuejuan1.blog.163.com/blog/static/54463100200992281135856/SAS可以把一组同为数值型或同为字符型的变量合在一起,使用同一个名字称呼,用下标来区分。这与通常的程序设计语言中的数组略有区别,通常的程序设计语言中数组元素没有对应的变量名,而SAS数组每个元素都有自己的变量名。 一、数值型数组 定义数值型数组的格式为: ARRAY 数组名(维数说明) 数组元素名列表(初始值表);例如:ARRAY tests(3) math chinese english (0, 0, 0);数组名是一个合法的SAS名字且不能与同 阅读全文

posted @ 2013-03-06 12:09 colipso 阅读(491) 评论(0) 推荐(0) 编辑

【sas notes excel】import
摘要:1 proc import datafile='F:\smstest.xls' dbms=excel out=mysas.smstest ;2 sheet="Sheet3";3 getnames=yes;4 run;注意:dbms=excel 阅读全文

posted @ 2013-03-06 11:02 colipso 阅读(314) 评论(0) 推荐(0) 编辑

【sas proc sql】子查询
摘要:1 proc sql feedback;2 select * from merge_a3 where flight>(select max(flight) from merge_b);4 quit;1 proc sql feedback;2 select * from merge_a3 where flight in (select flight from merge_b);4 quit;-----correlated subquery1 proc sql feedback;2 select * from merge_a a3 where fli... 阅读全文

posted @ 2013-03-05 16:15 colipso 阅读(1447) 评论(0) 推荐(0) 编辑

【sas Notel】merge
摘要:1 data merge_a; 2 input flight $ supervisor $; 3 datalines; 4 145 kang 5 150 miller 6 155 evanko 7 160 yale 8 ; 9 run;10 data merge_b;11 input flight $ destination $;12 datalines;13 145 brussels14 150 paris15 155 honolulu16 ;17 run;18 data merged;19 merge merge_a merge_b;20 ... 阅读全文

posted @ 2013-03-05 15:53 colipso 阅读(288) 评论(0) 推荐(0) 编辑

【sas proc sql】coalesce
摘要:1 data mylearn.coalesce; 2 input a $ 1-1 b $ 3-3; 3 datalines; 4 a e 5 b 6 c f 7 d g 8 h 9 ;10 run;11 proc sql feedback;12 select coalesce(a,b) from mylearn.coalesce;13 quit;14 proc print data=mylearn.coalesce;15 run;coalesce函数返回参数里面的第一个非空值。 阅读全文

posted @ 2013-03-05 11:17 colipso 阅读(1396) 评论(0) 推荐(0) 编辑

【sas proc sql】cross/union/natural join
摘要:1 proc sql;2 select a.a '#a#a sample',b.a from mylearn.outerjoin_a a cross join mylearn.outjoin_b b;3 quit;cross join 做两个表的笛卡尔积 ,如果有筛选条件,用where1 proc sql;2 select a.a '#a#a sample',b.a from mylearn.outerjoin_a a union join mylearn.outjoin_b b;3 quit;union join 仅做两表合并。1 proc sql;2 sel 阅读全文

posted @ 2013-03-05 10:02 colipso 阅读(1022) 评论(0) 推荐(0) 编辑

【sas proc sql】out join
摘要:1 data mylearn.outerjoin_a; 2 input a :$; 3 datalines; 4 a 5 b 6 c 7 d 8 e 9 f10 g11 ;12 run;13 data mylearn.outjoin_b;14 input b :$;15 datalines;16 b17 c18 d19 k20 ;21 run;22 proc sql;23 select * from mylearn.outerjoin_a a rig... 阅读全文

posted @ 2013-03-05 09:33 colipso 阅读(1080) 评论(0) 推荐(0) 编辑

【sas sql proc】inner join or outer join
摘要:1 proc sql; 2 title 'table 1+11'; 3 select * from mysas.ifthen1,mysas.ifthen11; 4 quit; 5 6 proc sql; 7 title 'table 1'; 8 select * from mysas.ifthen1; 9 10 title 'table11';11 select * from mysas.ifthen11;12 quit;第一段显示的是两表联合的笛卡尔积结果。第二段仅是分别显示两表。 1 proc sql; 2 title '... 阅读全文

posted @ 2013-03-04 09:54 colipso 阅读(2544) 评论(0) 推荐(0) 编辑

【sas sql proc】where or having
摘要:having作用类似于where区别在于where在group by之前执行;having作用于group by。1 proc sql;2 select sum(cmcc_fee) as sumfee,product_name,port3 from &groupset4 group by product_name,port5 having count(port)>2;6 quit; 阅读全文

posted @ 2013-03-01 12:04 colipso 阅读(1653) 评论(0) 推荐(0) 编辑

【sas proc sql】group by
摘要:1 proc sql;2 select sum(cmcc_fee) as sumfee,product_name,port3 from &groupset4 group by product_name,port;5 quit;在group by 后可以有多个维度。 阅读全文

posted @ 2013-03-01 11:48 colipso 阅读(2125) 评论(0) 推荐(0) 编辑

【sas proc sql】缺失值的替换
摘要:1 proc sql;2 select date,coalesce(gtone,1) as z_gtone,sum(calculated z_gtone) from &dataset;3 quit;4 proc sql;5 select * from &dataset6 where gtone is missing;7 quit;对于数据中的缺失值,可以用coalesce函数来对缺失值进行替换,在标准sql语句中等同于ifnull函数。 阅读全文

posted @ 2013-03-01 11:17 colipso 阅读(2641) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示