zoukankan      html  css  js  c++  java
  • SAS--sql

         proc sql;
            select empid,jobcode,salary, /*变量用comma隔开*/
                   salary*.06 as bonus   /*创建新变量*/
               from sasuser.payrollmaster
               where salary<32000
               order by jobcode;
         quit;
    
             proc sql;
            select empid,jobcode,salary,
                   salary*.06 as bonus
               from sasuser.payrollmaster
               where salary<32000
               order by 2 desc, 1 ;  *order变量位置,根据jobcode降序,再empid升序; 
         quit;
    
    
            proc sql;
            select salcomps.empid,lastname,  /*两个表有公共列时,必须指定该列的前缀*/
                   newsals.salary,newsalary
               from sasuser.salcomps,sasuser.newsals
               where salcomps.empid=newsals.empid
               order by lastname;
    
    proc sql;
       select therapy1999.month,walkjogrun,swim,
              treadmill,newadmit,
              walkjogrun+swim as Exercise
          from sasuser.therapy1999,sasuser.totals2000
          where therapy1999.month=totals2000.month;  /*两个表,变量前一定要加数据集名字*/
    quit;
    
    
    proc sql;
            select membertype,
                   sum(milestraveled) as TotalMiles
               from sasuser.frequentflyers
               group by membertype;   /*若没有上面的sum,功能和order一样*/
    proc sql;
       select sex, avg(age) as AverageAge,
              avg(weight) as AverageWeight
          from sasuser.diabetes
          group by sex;
    quit;
    /*创建sas.dataset*/
     proc sql;
            create table work.miles as
               select membertype,
                      sum(milestraveled) as TotalMiles
                  from sasuser.frequentflyers
                  group by membertype;
    
        proc print data=work.miles;
        run;
    
           proc sql;
            select jobcode,avg(salary) as Avg
               from sasuser.payrollmaster
               group by jobcode
               having avg(salary)>40000 and  avg(salary)<50000 /*和group连用,和where功能一样*/
               order by jobcode;

       

    Valar morghulis
  • 相关阅读:
    vue 富文本编译器 vue-quill-editor
    vue-拖拽的使用awe-dnd
    Dapper是什么?
    如何运用领域驱动设计
    面试官问我MySQL索引,我
    MySQL:你知道什么是覆盖索引吗?
    mysql覆盖索引与回表
    C#.NET 字符串转数组,数组转字符串
    MYSQL如何让主键使用BTREE索引
    MySQL大表优化方案 Mysql的row_format(fixed与dynamic)
  • 原文地址:https://www.cnblogs.com/super-yb/p/11808980.html
Copyright © 2011-2022 走看看