zoukankan      html  css  js  c++  java
  • 【SAS NOTES】retain

    data mysas.ifthen5;
         infile 'e:\ifthen.txt' dlm='09'x firstobs=2;
         input date gtone shen dong all;
         retain maxgtone; 
             maxgtone=max(maxgtone,gtone);
         retain minshen; 
             minshen=min(minshen,shen);
    run;
    proc print data=mysas.ifthen5;
    run;

    result

    Obs     date      gtone       shen       dong        all      maxgtone    minshen

          28    201104     526924    7565735    2230739    10323398      526924    6742289
          29    201105     537731    7561917    2263410    10363058      537731    6742289
          30    201106     556215    7479801    2280381    10316397      556215    6742289
          31    201107     582287    7530444    2323672    10436403      582287    6742289
          32    201108     627106    7309423    2296700    10233229      627106    6742289
          33    201109     673407    7171315    2264441    10109163      673407    6742289
          34    201110     701135    6982613    2211213     9894961      701135    6742289
          35    201111     743656    6686985    2141923     9572564      743656    6686985
          36    201112     791015    6533912    2146543     9471470      791015    6533912
          37    201201     847913    6675797    2096167     9619877      847913    6533912
          38    201202     867957    6562126    2063072     9493155      867957    6533912
          39    201203     931486    6610918    2087945     9630349      931486    6533912
          40    201204    1006850    6476150    2035887     9518887     1006850    6476150
          41    201205    1089899    6435717    2016858     9542474     1089899    6435717
          42    201206    1158009    6363637    2000173     9521819     1158009    6363637

    retain 可以让变量在数据步中每一条记录中都保持运算。

    用if then else 也可以实现类似效果。

  • 相关阅读:
    For-Each循环
    test
    网络学习一
    Struts2的interceptor
    Struts2的action解读
    js 读取<select>标签选项 索引
    java项目打jar包
    图解sendRedirect和forward的区别
    导入外部项目无法识别为Web项目无法部署到tomcat
    项目乱码的分析与解决
  • 原文地址:https://www.cnblogs.com/colipso/p/2875203.html
Copyright © 2011-2022 走看看