2011年8月13日

最近一直在跟着李东风的《统计软件教程》学习SAS,刚刚学完初等统计,感觉还没入门,找不到matlab编程时那种手顺的感觉。继续学习吧,加油!

    最近用spss处理数据,但是spss缺乏变量内的计算。想算出一个累积占比还得靠SAS
首先 数据手动导入命名class;
然后 数据按某一列降序排列;
proc sort data=class  out=class2;
by descending VAR2;
run;
最后 新加一列占比,并且算出累积占比;
data class1;
set class2;
format _all_;
retain getpost_sumzb;
getpost_sumzb+getpost_zhanbi;
retain sumbytes_sumzb;
sumbytes_sumzb+sumbytes_zhanbi;
chazhi=getpost_sumzb-sumbytes_sumzb;
run;
proc sort data=class1  out=class3;
by descending chazhi;
run;
data class_80;
set class1;
if getpost_sumzb<=0.8;
run;
 
如下是高手的方法特此引荐,以后细看:
 
data a;
input date :yymmn6.
      amt  
          ;
format date yymmn6.;
cards;
201101    100 
201102    200
201103    300
201104    400
201105    500
;
 data result1;
  do until(last);
    set a end=last;
        ytd_amt+amt;
        output;
  end;
 run;
 proc sql;
    create table result2 as
      select distinct (a.date),a.amt, sum(b.amt) as ytd_amt
            from (select a.*,monotonic() as n from a) a
                  join  (select a.*,monotonic() as n from a) b
                    on a.n ge b.n
                      group by a.n;
 quit;
 
错误: ERROR: Width specified for format F is invalid
    或 ERROR: 为输出格式“F”指定的宽度无效

The following errors occur after you try to import an SPSS file into a SAS data set:

ERROR: The decimal specification of 2 must be less than the width specification of 2. ERROR: The decimal specification of 2 must be less than the width specification of 2. ERROR: The decimal specification of 2 must be less than the width specification of 2. ERROR: Width specified for format F is invalid. ERROR: Width specified for format F is invalid. ERROR: Width specified for format F is invalid.

For example, these errors occur when you submit an IMPORT procedure similar to the following:

proc import datafile="c:\temp\test.sav" out=xyz dbms=sav; run; data test1; set xyz; run;

The errors occur when the lengths of the SPSS fields are read into the SAS® System as negative values.

To circumvent this error, use FORMAT _ALL_ statement in the DATA step, as shown in the following output:

data test1; set xyz; format _all_; run; NOTE: There were 6 observations read from the data set WORK.XYZ. NOTE: The data set WORK.TEST1 has 6 observations and 642 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds

最新文章

  1. C与指针(结构体指针,函数指针,数组指针,指针数组)定义与使用
  2. 测可用!ecshop立即购买和加入购物车按钮共存的方法
  3. wp8.1 Study13:在WP8.1中分享文件和数据
  4. RabbitMQ C# 例子 -摘自网络
  5. asp.net C#检查URL是否有效
  6. Android:requestWindowFeature应用程序窗体显示状态操作
  7. Stage3D学习笔记(三):使用GPU绘制一个图片
  8. Oracle数据库小知识,改数据库数据
  9. 动态规划(DP计数):HDU 5116 Everlasting L
  10. Eclipse&amp;Spring开发开发环境配置
  11. java数据结构之二叉树的实现
  12. dedecms织梦上下页标签和CSS
  13. 腾讯这套SpringMvc面试题你了解多少?(面试必备)
  14. Filebeat占用内存和CPU过高问题排查
  15. App 性能相关
  16. CentOS下查找java环境变量
  17. C#模拟HTTP请求Post JSON
  18. day37 mysql数据库学习
  19. KVM NAT网络模式配置
  20. vs2017搭建linux c++开发环境

热门文章

  1. No changes detected or App &#39;blog&#39; could not be found. Is it in INSTALLED_APPS?
  2. init&amp;initWithFrame&amp;initWithCoder
  3. Spark Streaming概念学习系列之Spark Streaming的竞争对手
  4. 备份IIS
  5. week5_notebooke1
  6. WebApi不支持跨域访问
  7. signature验证/salt验证/token验证的作用
  8. SQL Server 检测到基于一致性的逻辑 I/O 错误
  9. Mac Dropbox 文件不显示同步图标 解决
  10. Unity 点击屏幕发射射线 代码