/*输出*/ proc export data =  a                outfile = "Z:\2012工作\数据分配\5.15数据分配\某某.xls"  			  dbms = excel replace; 			  sheet = "a"; run; /*输入*/ PROC IMPORT OUT= WORK.ordern_temp             DATAFILE= "Z:\数据平台\DATA\TXT\订单_2012\order_&ym..xls"              DBMS=EXCEL REPLACE;      SHEET="c6_searchTask2$";       GETNAMES=YES;      MIXED=NO;      SCANTEXT=NO;      USEDATE=YES;      SCANTIME=YES;      TEXTSIZE=2048;  RUN;  /*追加数据*/ proc append base = src.order_cust data = order_cust; run;   /*根据出生日期取年龄*/ data dingdan_cust_price1;   set dingdan_cust_price;    if (trim(left(CUST_BIRTHDAY)) ^= "" and length(trim(left(CUST_BIRTHDAY))) >= 8 and count(CUST_BIRTHDAY,"*") = 0) then do;       CUST_BIRTHDAY_C = substr(trim(left(CUST_BIRTHDAY)),1,8);       CUST_BIRTH = MDY(substr(CUST_BIRTHDAY_C,5,2),substr(CUST_BIRTHDAY_C,7,2),substr(CUST_BIRTHDAY_C,1,4));       format CUST_BIRTH yymmdd10.;       CUST_AGE = 2012 - year(CUST_BIRTH);    end; run;  /*按某一变量计算总和*/ data dx_xiadan_cust1 ;   set dx_xiadan_cust ;   by cust_hand_phone;   if first.cust_hand_phone then do;     order_price_dx_tot = order_price;   end;   else do;     order_price_dx_tot + order_price;   end;   if last.cust_hand_phone; run;   /*汇总分类。如果class改成by，则输出具体，比如，男的和女的分两个表格*/ proc summary data =data_base_region sum mean median max maxdec=n fw=w;   class CUST_SEX  CUST_AGE_cls  cust_province ;   ways 0 to 1;   var order_price  ;   output out = order_price_stat( drop = _type_ _freq_ ) sum = order_price_sum ; run; /*maxdec为输出统计量数值时最多包含的小数位数，w为每个统计量显示数值的宽度（字符数）*/  /*TABLE选项设置，SUM可计算加和，COLPCTSUM可计算占比*/ proc tabulate data = order_ob_rate_d missing out = rate_summ (drop = _table_ _page_ _type_ rename = (order_price_sum = order_price_sum order_price_pctsum_0 = order_price_sum_pct                                                                   order_profit_sum = order_profit_sum order_profit_pctsum_0 = order_profit_sumpct  ));   class rate_product_type4;   VAR ORDER_PRICE ORDER_PROFIT ;   TABLE (rate_product_type4 ),(ORDER_PRICE * (SUM COLPCTSUM )  ORDER_PROFIT * (SUM COLPCTSUM ) ); RUN;  /*导出变量名和变量名称*/  proc sql noprint;   create table cc   as   select name ,label   from sashelp.Vcolumn   where trim(left(libname)) = "WORK"  and trim(left(memname)) = "T_ORDER_PBT5"; quit;  /*数据类型转换*/  data a;   set src.Order_product_cls_20120708 ;   cc = put(order_no,$32.); run;   /*PROC FREQ*/ proc format ;   value $ a 1="male" 2="female";   value b 0-100="below100" 100<-200="100-200"           200<-high="above 200";  proc freq data=Ztdx_t7 order=formatted;   tables product_num/nocum missing out=b;   format  sex $ a. product_num b.;   weight x; run;    /*order分为DATA:按数据集中数据值出现的次序排列            formatted 按数据输出格式值的次序            freq按频数降序            internal缺省情况，按数据值的次序*/   /**summary/mean*/  data csv(drop = year quyear month qumonth day quday hour minute second);    set csv1;    if (length(time_1) >= 13) then do;       year = 2012;       quyear = substr(time_1,6,length(time_1)-5);       month = substr(quyear,1,index(quyear,"-")-1);       qumonth = substr(quyear,index(quyear,"-")+1,length(quyear)-index(quyear,"-"));       day = substr(qumonth,1,index(qumonth," ")-1);       quday = substr(qumonth,index(qumonth," ")+1,length(qumonth)-index(qumonth," "));       hour = substr(quday,1,index(quday,":")-1);       minute = substr(quday,index(quday,":")+1,length(quday)-index(quday,":"));       second = 0;    end;    format time datetime19.;    time = dhms(MDY(month,day,year),hour,minute,second);    label time = "下单时间"; run; OB_DTTM= dhms(MDY(07,23,2012),hour(time()),minute(time()),second(time()));   /*分位数*/ proc univariate data = order_cls_all;    var order_price_t;    class PRODUCT_CLS_123;    output out = order_cls_all_summ n = orderNum min = minPrice pctlpts = 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95                                                    pctlpre = p5 p10 p15 p20 p25 p30 p35 p40 p45 p50 p55 p60 p65 p70 p75 p80 p85 p90 p95    max = maxPrice; run;  /*抽样*/ proc surveyselect data=cust_old out=Sample       samplesize = 60; run;   proc surveyselect data = order_meta noprint    method = srs n = tiqu  selectall out = b_sample;    strata laidan_dt order_source cust_sex price_cls f3; run;