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

SAS小记的更多相关文章

  1. [原]Paste.deploy 与 WSGI, keystone 小记

    Paste.deploy 与 WSGI, keystone 小记 名词解释: Paste.deploy 是一个WSGI工具包,用于更方便的管理WSGI应用, 可以通过配置文件,将WSGI应用加载起来. ...

  2. MySql 小记

    MySql  简单 小记 以备查看 1.sql概述 1.什么是sql? 2.sql发展过程? 3.sql标准与方言的关系? 4.常用数据库? 5.MySql数据库安装? 2.关键概念 表结构----- ...

  3. Git小记

    Git简~介 Git是一个分布式版本控制系统,其他的版本控制系统我只用过SVN,但用的时间不长.大家都知道,分布式的好处多多,而且分布式已经包含了集中式的几乎所有功能.Linus创造Git的传奇经历就 ...

  4. 广州PostgreSQL用户会技术交流会小记 2015-9-19

    广州PostgreSQL用户会技术交流会小记 2015-9-19 今天去了广州PostgreSQL用户会组织的技术交流会 分别有两个session 第一个讲师介绍了他公司使用PostgreSQL-X2 ...

  5. 东哥读书小记 之 《MacTalk人生元编程》

         一直以来的自我感觉:自己是个记性偏弱的人.反正从小读书就喜欢做笔记(可自己的字写得巨丑无比,尼玛不科学呀),抄书这事儿真的就常发生俺的身上. 因为那时经常要背诵课文之类,反正为了怕自己忘记, ...

  6. Paypal支付小记

    Paypal支付小记 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !impo ...

  7. linux 下cmake 编译 ,调用,调试 poco 1.6.0 小记

    上篇文章 小记了: 关于 Poco::TCPServer框架 (windows 下使用的是 select模型) 学习笔记. http://www.cnblogs.com/bleachli/p/4352 ...

  8. mongodb入门学习小记

    Mongodb 简单入门(个人学习小记) 1.安装并注册成服务:(示例) E:\DevTools\mongodb3.2.6\bin>mongod.exe --bind_ip 127.0.0.1 ...

  9. 【日常小记】统计后缀名为.cc、.c、.h的文件数【转】

    转自:http://www.cnblogs.com/skynet/archive/2011/03/29/1998970.html 在项目开发时,有时候想知道源码文件中有多少后缀名为.cc..c..h的 ...

随机推荐

  1. 4. Median of Two Sorted Arrays[H]两个有序数组的中位数

    题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the midian of the ...

  2. caffe mnist实例 --lenet_train_test.prototxt 网络配置详解

    1.mnist实例 ##1.数据下载 获得mnist的数据包,在caffe根目录下执行./data/mnist/get_mnist.sh脚本. get_mnist.sh脚本先下载样本库并进行解压缩,得 ...

  3. 关于swift构造方法

    switf 中如果遇到这样的错,,,大概错误就是,"必须要调用父类的构造方法",,可是呢,,调用了super.init()  不就是调用了构造方法了吗? 结果上去一查,,结果一名外 ...

  4. 利用PBFunc在Powerbuilder中进行图片格式转换

    利用PBFunc的n_pbfunc_image对象可以方便的进行图片格式的转换与大小转换 支持相互转换的格式有以下几种: FORMAT_BMP //bmp格式FORMAT_GIF  //gif格式FO ...

  5. ZOJ 3019 Puzzle

    解题思路:给出两个数列an,bn,其中an,bn中元素的顺序可以任意改变,求an,bn的LCS 因为数列中的元素可以按任意顺序排列,所以只需要求出an,bn中的元素有多少个是相同的即可. 反思:一开始 ...

  6. GitHub报错error: bad signature

    Git报错 bad signature 将文件提交到仓库时,抛出以下错误: 报错 Roc@DESKTOP-AF552U2 MINGW64 /e/note/Git (master) $ git add ...

  7. Node_进阶_2

    第二天 一.复习: Node.js开发服务器.数据.路由.本地关心效果,交互. Node.js实际上是极客开发出的一个小玩具,不是银弹.有着别人不具备的怪异特点: 单线程.非阻塞I/O.事件驱动. 实 ...

  8. PHP SOAP 使用示例

    soap_client.php <?php try { $client = new SoapClient( null, array('location' =>"http://lo ...

  9. [读书笔记] Python数据分析 (一) 准备工作

    1. python中数据结构:矩阵,数组,数据框,通过关键列相互联系的多个表(SQL主键,外键),时间序列 2. python 解释型语言,程序员时间和CPU时间衡量,高频交易系统 3. 全局解释器锁 ...

  10. 更新Maven的本地库

    1. 更新Maven的本地库 通常情况下,可改变默认的 .m2 目录下的默认本地存储库文件夹到其他更有意义的名称,例如, maven-repo 找到 {M2_HOME}\conf\setting.xm ...