zoukankan      html  css  js  c++  java
  • SAS--chapter9描述统计(means freq)

    描述统计 means  /  freq

    libname clinic 'D:sas';
    proc means data=clinic.admit;
    run;               *num变量自动计算mean,sd,max,min;
    proc means data=clinic.admit median range; *prco means data=  statistic;
    run;
    proc means data=clinic.admit min maxdec=2; *最大的小数点为2;
    run;
    proc means data=clinic.admit ;
        var age height;           *指定变量 or  item1-item6;
    run;
    proc means data=clinic.admit ;
        var age height;  
        class sex;  *根据sex将数据分组,可以多个变量。该变量值必须是有限个个数,cha和num都可以; 
    run;
    
    
    proc sort data=clinic.admit out=clinic.admitsort;
        by sex actlevel;         
    run;
    proc means data=clinic.admitsort ;
        var height weight;
        by sex actlevel;     *类似与class,但是需要提前sort;
    run;
    
    *输出;
    proc means data=clinic.admit noprint;  *不打印上半部分;
        var age height;    
        class sex; 
            output out=work.data_gender    
            mean = aveage aveheight;      *输出 opt=libref.dataname mean=(输出均数),aveage=变量名;
    run;
    proc print data=work.data_gender;   *print刚刚的输出;
    run;
    proc freq data=clinic.admit2;  *数据集中每一个分类变量的频数,百分比,累计频数,累计百分比;
    run;
    proc freq data=clinic.admit2;  
        table paid  location;       *列出某些分类变量  or  table item1-item4;
    run;
    proc freq data=clinic.admit2 ;  
        table paid location /nocum;   *不显示累计频数和累计百分比;
    run;
    
    proc freq data=clinic.admit2 ; 
        tables paid*location;   *crosstable ,cells contain 频数,total freq,row f,column f;
    run;                        *还可以是 a*b*c,a为level,b is row , c is column:
    
    *combine format;
    proc format;
        value wtfmt low-139='< 140'
                    140-180='140-180'
                    181-high='> 180';
    
        value htfmt low-64='< 5''5"'
                    65-70='5''5-10"'
                    71-high='> 5''10"';
    run;
    proc freq data=clinic.diabetes;
        tables weight*height;
        format weight wtfmt. height htfmt.;
    run;
    
    proc freq data=clinic.admit2 ; 
        tables paid*location / crosslist;  *check the different with no crosslist;
    run;
    
    proc freq data=clinic.admit2 ; 
        tables paid*location / list;    *more compact and clear
    run;
    
    proc freq data=clinic.admit2 ; 
        tables paid*location / nofreq norow nocol;   *suppress table;
    run;
    proc means data=clinic.heart min max maxdec=1;
       var arterial heart cardiac urinary;
       class survive sex;
    run;
    
    
    proc summary data=clinic.diabetes;
       var age height weight;
       class sex;
       output out=work.sum_gender
          mean=AvgAge AvgHeight AvgWeight;
    run; 
    
    
    proc freq data=clinic.heart order=freq;
       tables sex*survive*shock / nopercent list;
    run;
    

      

    Valar morghulis
  • 相关阅读:
    博客园
    未释放的已删除文件
    ssh连接缓慢
    剑指 Offer 38. 字符串的排列
    剑指 Offer 37. 序列化二叉树
    剑指 Offer 50. 第一个只出现一次的字符
    剑指 Offer 36. 二叉搜索树与双向链表
    剑指 Offer 35. 复杂链表的复制
    剑指 Offer 34. 二叉树中和为某一值的路径
    剑指 Offer 33. 二叉搜索树的后序遍历序列
  • 原文地址:https://www.cnblogs.com/super-yb/p/11661723.html
Copyright © 2011-2022 走看看