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. 树状数组(Binary Indexed Tree(BIT))

    先不说别的,这个博客为我学习树状数组提供了很大帮助,奉上传送门 http://blog.csdn.net/int64ago/article/details/7429868 然后就说几个常用的操作 in ...

  2. Spring《一》

    1.支持的注入方式 构建注入,set注入 2.bean属性 id.name.class.singleton(true.false).depends-on="date"(初始化依赖) ...

  3. ES6的基本语法

    ES6 详细参考页面 简介 ECMAScript和JavaScript的关系是,前者是后者的规格,后者是前者的一种实现.一般来说,这两个词是可以互换的. let命令 ES6新增了let命令,用来声明变 ...

  4. 关于idlf无法输入中文的解决办法

    最近在学习python 但是刚开始写程序的时候发现无法输入中文  上网查发现有不少mac端的IDLF也存在这个问题 导致这个问题的原因可能不唯一 但是大多数原因应该是Mac 系统自带的 Tcl/Tk ...

  5. SQL Server-聚焦移除Bookmark Lookup、RID Lookup、Key Lookup提高SQL查询性能

      前言 前面几节都是讲的基础内容,本节我们讲讲索引性能优化,当对大数据进行处理时首先想到的就是索引,一旦遇到这样的问题则手忙脚乱,各种查资料,为何平常不扎实基本功呢,我们由浅入深,简短的内容,深入的 ...

  6. mysql面试几个问题

    1.为什么InnoDB表最好要有自增列做主键? InnoDB引擎表是基于B+树的索引组织表(IOT) 关于B+树 (图片来源于网上) B+ 树的特点: a.所有关键字都出现在叶子结点的链表中(稠密索引 ...

  7. eclipse搭建golang for windows

    用惯了eclipse,所以.... golang windows开发环境 参考文档:http://golang.org/doc/install 1.下载go安装包http://code.google. ...

  8. iOS9 & Xcode7 下设置LaunchImage启动图片 问题及解决

    最近在学习iOS开发,碰到一个设置启动图片的问题,怎么也搞不定,综合网上种种资料后Done,现在把完整过程写一下. 这里以建立一个空的Single View Application 为演示基础. 1. ...

  9. CF950B Intercepted Message_双指针法

    本来想直接上权值线段树维护区间最值,不过可以用双指针法,就使问题变得简洁. Code: #include<iostream> using namespace std; const int ...

  10. JS取出特定字符前后的字符串,针对一串字符里面的单个字符前后的字符串

    //针对一串自负里面的单个字符前后的字符串<!doctype html> <html> <head> <meta charset="utf-8&qu ...