01 2013 档案

【SAS NOTES】脏数据
摘要:从明细文件着手做分析,最痛恨的就是脏数据导致分析出错。例如1月的数据格式是有6个字段,结果到6月就只剩5个字段,到了9月又产生了11个字段。即使是同一个字段,不同周期的数据格式也不一致,例如2012-8-19 12:16 到了九月就成了2012-8-19 12:16:08 数据格式的问题纠结很久。所以说数据清洗很重要。上次分析的代码因解决格式问题更新如下: 1 data guanhui.buydetail;/*导入2012年莞惠网交易明细汇总*/ 2 infile 'E:\交易明细汇总.txt' firstobs=2; 3 input file & :$300. @@; 阅读全文

posted @ 2013-01-31 09:49 colipso 阅读(280) 评论(0) 推荐(0) 编辑

【SAS NOTES】输出结果到excel
摘要:1 ods html file="E:\汇总.xls";2 proc print data=guanhui.buydetail_evedetailfee;3 run;4 ods html close;为什么是html那?是因为用csv的话所有数据都集中在一个单元格里,非我所需。而网上1 ods tagsets.excelxp file="d:\test.xls" options(sheet_name="print") style=analysis;2 proc print data=sashelp.class;run;3 ods ta 阅读全文

posted @ 2013-01-30 16:46 colipso 阅读(859) 评论(0) 推荐(0) 编辑

【SAS NOTES】转载 sas函数&模块
摘要:一、数学函数ABS(x) 求x的绝对值。 MAX(x1,x2,…,xn) 求所有自变量中的最大一个。 MIN(x1,x2,…,xn) 求所有自变量中的最小一个。 MOD(x,y) 求x除以y的余数。 SQRT(x) 求x的平方根。 ROUND(x,eps) 求x按照eps指定的精度四舍五入后的结果,比如ROUND(5654.5654,0.01) 结果为5654.57,ROUND(5654.5654,10)结果为5650。 CEIL(x) 求大于等于x的最小整数。当x为整数时就是x本身,否则为x右边最近的整数。 FLOOR(x) 求小于等于x的最大整数。当x为整数时就是x本身,否则为x左边最近的 阅读全文

posted @ 2013-01-30 11:36 colipso 阅读(775) 评论(0) 推荐(0) 编辑

【SAS NOTES】实际分析应用
摘要:1 data guanhui.visit_8_12;/*导入客户访问情况*/ 2 infile 'E:\****.txt' dlm='|' firstobs=2; 3 input user :$11. serv_number :$11. log_time :$16. log_IP :$15. content :$100.; 4 log_date=scan(log_time,1,' '); 5 log_year=scan(log_date,1,'-'); 6 log_month=scan(log_date,2,'-' 阅读全文

posted @ 2013-01-30 11:11 colipso 阅读(374) 评论(0) 推荐(0) 编辑

【SAS NOTE】substr字符串提取函数
摘要:substr(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个字符 阅读全文

posted @ 2013-01-29 09:29 colipso 阅读(8727) 评论(0) 推荐(0) 编辑

【SAS NOTE】“:”&时间处理
摘要:1 data mysas.guanhui_nov; 2 infile 'E:\SAS\mysas\visit_guanhui_nov.txt' dlm='|' firstobs=2; 3 input user :$11. serv_num:$11. log_date :$14. log_IP :$15. content :$50.; 4 my_year=input(substr(log_date,1,4),4.); 5 my_mon=input(substr(log_date,6,2),2.); 6 my_day=input(substr(log_... 阅读全文

posted @ 2013-01-28 22:55 colipso 阅读(774) 评论(0) 推荐(0) 编辑

【SAS NOTES】data格式
摘要: 阅读全文

posted @ 2013-01-28 16:43 colipso 阅读(210) 评论(0) 推荐(0) 编辑

【SAS NOTES】ods
摘要:1 data mysas.mmsone; 2 infile 'E:\SAS\mysas\MMS1.txt' dlm='09'x firstobs=2; 3 input date city $ wangnei wangjian guoji shangxing wangneid wangjiand 4 guojid alld allwangnei allwangjian allguoji allall upfeetiao downfeetiao; 5 run; 6 proc sort data=mysas.mmsone; 7 by city; 8... 阅读全文

posted @ 2013-01-27 22:46 colipso 阅读(1800) 评论(1) 推荐(0) 编辑

【SAS NOTE】安装注意语言选项
摘要:在安装sas9.1.3时需要注意安装语言环境同时选中中文和英文,这样在分析数据时就可以支持中文内容。 阅读全文

posted @ 2013-01-27 11:13 colipso 阅读(286) 评论(0) 推荐(0) 编辑

【SAS NOTE】proc report
摘要:proc report用来生成报告。1 proc report data=mysas.mms nowindows headskip;2 column date wangnei wangjian guoji;3 define wangnei /analysis;4 define date /group;5 run;define-约定特定变量的组织方式。注意 define 的参数用/analysis等来表示,不要忘记/.1 proc report data=mysas.mms nowindows headskip;2 column date,(wangnei wan... 阅读全文

posted @ 2013-01-26 22:49 colipso 阅读(1616) 评论(0) 推荐(0) 编辑

【SAS NOTE】tabulate
摘要:1 data mysas.mms; 2 infile 'E:\SAS\mysas\mms.txt' dlm='09'x firstobs=2; 3 input date city wangnei wangjian guoji shangxing wangneid wangjiand guojid 4 alld allwangnei allwangjian allguoji allall upfeetiao downfeetiao; 5 run; 6 proc print data=mysas.mms; 7 run; 8 proc tabulate... 阅读全文

posted @ 2013-01-26 17:55 colipso 阅读(501) 评论(0) 推荐(0) 编辑

【SAS NOTE】FREQ
摘要:1 data mysas.frequence;2 infile 'E:\SAS\mysas\frequence.txt' firstobs=2;3 input a b c;4 proc freq data=mysas.frequence;5 tables a a*b;6 run;可以从明细中来统计某一类产品的订购数等。 阅读全文

posted @ 2013-01-26 16:47 colipso 阅读(351) 评论(0) 推荐(0) 编辑

【SAS NOTE】sas 9.2 安装
摘要:见:http://blog.sina.com.cn/s/blog_840b11ae01019333.html一、SAS9.2的下载SAS一般比较大,所以要有好的网才行(我们宿舍联通10M)。网上下载资源虽多,但很多不靠谱,在此我提供一个下载地址:sas9.2版本下载地址ed2k://|file|[SAS.9.2多国语言版(更新9.21.TS2M2版)].SAS9_2_Disk1.iso|4315152384|3b745cacd89fb908859d8a5aa7b8063e|/ed2k://|file|[SAS.9.2多国语言版(更新9.21.TS2M2版)].SAS9_2_Disk2.iso| 阅读全文

posted @ 2013-01-26 15:40 colipso 阅读(2765) 评论(0) 推荐(0) 编辑

【SAS NOTE】OUTPUT
摘要:1 proc means data=mysas.ifthen11;2 var year date gtone shen dong all;3 output out=mysas.tryout max(gtone shen)=a b;4 run;5 proc print data=mysas.tryout;6 run;用output可以将means的结果另存到另一个数据集中。1 proc means data=mysas.ifthen11;2 var year date gtone shen dong all;3 by year;4 output o... 阅读全文

posted @ 2013-01-25 20:37 colipso 阅读(339) 评论(0) 推荐(0) 编辑

【SAS NOTE】MEANS
摘要:1 data mysas.ifthen11;2 infile 'e:\ifthen.txt' firstobs=2;3 input date yymmn6. gtone shen dong all;4 year=year(date);5 run;6 proc means data=mysas.ifthen11 max min n nmiss sum range ;7 by year;8 where year(date)<=2011;9 run;means过程很适合统计月度或年度数据。在常规分析中会经常用到。其中by字句做归类,where 做筛选。 阅读全文

posted @ 2013-01-25 19:45 colipso 阅读(243) 评论(0) 推荐(0) 编辑

【SAS NOTES】_NULL_
摘要:Data _NULL_;........用于在数据步中执行操作,但不产生数据集。_NULL_ tells sas not to bother writing a sas data set,and makes the program run slightly faster. 阅读全文

posted @ 2013-01-25 19:04 colipso 阅读(368) 评论(0) 推荐(0) 编辑

【SAS NOTE】用file+put实现结果输出
摘要:1 data mysas.ifthen10;2 infile 'e:\ifthen.txt' firstobs=2;3 input date yymmn6. gtone shen dong all;4 y=year(date);5 m=month(date);6 format date yymmn6.;7 file 'e:\output.txt' print;8 put y '年' m 'm,getong sms users number is' gtone;9 run; put的好处是可以直接根据变量生成文本结果报告。同时需要注 阅读全文

posted @ 2013-01-25 19:01 colipso 阅读(425) 评论(0) 推荐(0) 编辑

【SAS NOTES】print&format
摘要:proc print data=mysas.sort1; sum gtone shen dong all;run; 可以在print中增加sum选项来直接汇总值。【the little sas book】standard fromats in page 131. 1 data mysas.formatone; 2 infile 'e:\fromatesone.txt' firstobs=2; 3 input gender age; 4 proc format ; 5 value gendera 1='male' 6 2='female... 阅读全文

posted @ 2013-01-25 18:40 colipso 阅读(234) 评论(0) 推荐(0) 编辑

【SAS NOTE】where & time
摘要:1 proc print data=mysas.ifthen8;2 format date yymmn6.;3 where year(date) < 2010 and month(date)<5;4 run;对时间的筛选处理建议使用year month等函数。在sort中用 Nodupkey DUPOUT=extraobs;可以用来删除重复项。 阅读全文

posted @ 2013-01-25 18:13 colipso 阅读(243) 评论(0) 推荐(0) 编辑

【SAS NOTES】$ / #
摘要:对于data过程,文本类变量一定要加 $ 同一个observation跨行的话用/ 或#来连接。 阅读全文

posted @ 2013-01-25 13:55 colipso 阅读(289) 评论(0) 推荐(0) 编辑

【SAS NOTES】proc contents&OF
摘要:proc contents data=mysas.ifthen6 position;run;用来查看变量顺序【使用变量缩写】/*OF*/data mysas.ifthen8; infile 'e:\ifthen.txt' dlm='09'x firstobs=2; input date yymmn6. sms_gtone sms_shen sms_dong sms_all; sum=sum(OF sms:);run;proc print data=mysas.ifthen8;run;SAS的变量缩写功能很赞,注意的是在OF 后的变量加:一些特殊变量缩写_ALL_ 阅读全文

posted @ 2013-01-24 17:15 colipso 阅读(1075) 评论(0) 推荐(0) 编辑

【SAS NOTES】array+do to
摘要:array的好处是可以通过循环来对变量进行操作。do to sas语句中对于循环的控制。data mysas.ifthen7; infile 'e:\ifthen.txt' dlm='09'x firstobs=2; input date yymmn6. gtone shen dong all; array sms(4) gtone shen dong all; do i=1 to 4; if YEAR(date)=2009 then sms(i)=sms(i)*10; end;run;proc print data=mysas.ifthen7;ru... 阅读全文

posted @ 2013-01-24 16:47 colipso 阅读(576) 评论(0) 推荐(0) 编辑

【SAS NOTES】retain
摘要:data mysas.ifthen5; infile 'e:\ifthen.txt' dlm='09'x firstobs=2; input date gtone shen dong all; retain maxgtone; maxgtone=max(maxgtone,gtone); retain minshen; minshen=min(minshen,shen);run;proc print data=mysas.ifthen5;run;resultObs date gtone shen dong all maxgton... 阅读全文

posted @ 2013-01-24 16:15 colipso 阅读(772) 评论(0) 推荐(0) 编辑

【SAS Notes】If then statements
摘要:【回顾内容】data mysas.ifthen;infile 'E:\ifthen.txt' dlm='09'x firstobs=2;input date gtone shen dong all;run;1.当数据来源于excel dlm的参数为'09'x in ASCII 09 is the hexadecimal equivalen of a tab character,and the notation '09'x means a hexadecimal 092.firstboservation【if then do end 阅读全文

posted @ 2013-01-24 15:32 colipso 阅读(1150) 评论(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

导航

统计

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