上一页 1 ··· 58 59 60 61 62 63 64 65 66 ··· 71 下一页

2013年2月9日

【SAS NOTES】系统自带变量+%if

摘要: 1、&sysdate &sysday2、在宏中使用%if1 %macro select(num= );2 %if &num<15 %then %let date='201112';3 %else %let date ='201201';4 proc print data=mysas.Gprsprice_order;5 where date=&date;6 run;7 %mend;8 %select(num=10);%if 可以和%let一起使用 阅读全文

posted @ 2013-02-09 11:25 colipso 阅读(512) 评论(0) 推荐(0) 编辑

【SAS NOTES】宏

摘要: 1、宏名称前加% 宏变量前加&例如:%let abc=this is an instance;在使用中需要用&abc的格式。同时字符型宏变量在赋值时不需要加上引号。sas会在单引号引用的文本中替换宏变量,如果需要,则需要对文本加上双引号。1 %let city=dg;2 proc print data=mysas.mmstwo;3 where city="&city";4 run;在使用中注意在文本赋值上使用双引号。2、定义宏片段1 %macro sample;2 proc print data=mysas.mmstwo;3 where city=& 阅读全文

posted @ 2013-02-09 11:08 colipso 阅读(961) 评论(0) 推荐(0) 编辑

2013年2月4日

【SAS NOTE】在proc means中根据某变量的范围进行统计+proc format

摘要: 1 proc format; 2 value feegroup 3 low-500='0~500' 4 501-1000='500~1000' 5 1001-5000='1000~5000' 6 5001-high='>5000'; 7 run; 8 proc means data=guanhui.buedetail_same_sum_fee; 9 var serv_number_num;10 class sumfee;11 format sumfee feegroup.;12 run;注意:1、proc format 后v 阅读全文

posted @ 2013-02-04 15:22 colipso 阅读(1347) 评论(0) 推荐(0) 编辑

2013年2月3日

【SAS NOTES】在一个data中生成多个数据集

摘要: 利用if判断+output的选项实现该功能。 1 data mysas.mmsuser_dec mysas.mmsuser_nov mysas.mmsuser_other; 2 infile 'E:\SAS\mysas\mmsuser.txt' dlm='09'x firstobs=2; 3 input date $ city $ a b c d; 4 if date='201211' then output mysas.mmsuser_dec; 5 else if date='201212' then output mysas. 阅读全文

posted @ 2013-02-03 20:49 colipso 阅读(3115) 评论(0) 推荐(0) 编辑

【SAS NOTES】update

摘要: 类似merge,update可以对数据集进行更新,但源数据集需要对关键字进行排序。而且备用数据集的结构要同源数据集保持一致。 1 data mysas.mmsuserdec; 2 infile 'E:\SAS\mysas\mmsuserdec.txt' dlm='09'x firstobs=2; 3 input date $ city $ a b c d; 4 run; 5 data mysas.mmsuserdec_replace; 6 infile 'E:\SAS\mysas\mmsuserdec_replace' dlm='09&# 阅读全文

posted @ 2013-02-03 20:27 colipso 阅读(519) 评论(0) 推荐(0) 编辑

【SAS NOTES】两个数据集merge

摘要: 根据关键字,将多个数据集的相同关键字的数据合并到同一行。前提:1、数据集需要按照关键字排序、2、多个数据集除了关键字有相同变量名外,其余想合并到一起的变量其变量名不能相同,否则不能合并。 1 data mysas.mmsuserdec; 2 infile 'E:\SAS\mysas\mmsuserdec.txt' dlm='09'x firstobs=2; 3 input date $ city $ a b c d; 4 run; 5 data mysas.mmsusernov; 6 infile 'E:\SAS\mysas\mmsusernov.txt 阅读全文

posted @ 2013-02-03 14:50 colipso 阅读(6294) 评论(0) 推荐(1) 编辑

2013年2月2日

【SAS NOTES】两个数据集直接合并-不考虑关键字匹配

摘要: 1.sas会根据变量名进行直接合并,对于不同的变量名在其他数据集的数据里直接置空值。1 data mysas.gprsprict_cal_mer;2 set mysas.gprsprice_cal mysas.gprsprice;3 run;2.如果合并的两个或多个数据集已经根据某关键字排序,那么新数据集可以用如下方式在生成的时候直接排序。1 data mysas.gprsprice_order;2 set mysas.gprsprice_cal mysas.gprsprice;3 by date;4 run; 阅读全文

posted @ 2013-02-02 20:30 colipso 阅读(1773) 评论(0) 推荐(0) 编辑

【SAS NOTES】if then和if的区别

摘要: 21 data mysas.gprsprict_cal_mer;22 set mysas.gprsprice_cal mysas.gprsprice;23 if shen<0.04 then shen_a=shen*10;24 run;与27 data mysas.gprsprict_cal_mer;28 set mysas.gprsprice_cal mysas.gprsprice;29 if shen<0.04;30 shen_a=shen*10;31 run;的结果有区别,对if来讲,不符合条件的数据会直接忽略,而if ... 阅读全文

posted @ 2013-02-02 20:17 colipso 阅读(1529) 评论(0) 推荐(0) 编辑

【SAS NOTES】data set if

摘要: data mysas.gprsprice_cal; set mysas.gprsprice; if guang<0.04; guang_a=guang*10;run;只有符合if条件的数据才会被放入新的数据集中。 阅读全文

posted @ 2013-02-02 20:10 colipso 阅读(445) 评论(0) 推荐(0) 编辑

2013年2月1日

【SAS NOTES】kindex判断字符串中是否含某子字符串& 用where在data步中选择部分数据

摘要: Syntax KINDEX(source, excerpt)Argumentssource specifies the character expression to search.excerpt specifies the string of characters to search for in the character expression.Tip: Enclose a literal string of characters in quotation marks.------------------------------------------------------------- 阅读全文

posted @ 2013-02-01 16:18 colipso 阅读(6584) 评论(0) 推荐(0) 编辑

上一页 1 ··· 58 59 60 61 62 63 64 65 66 ··· 71 下一页

导航