zoukankan      html  css  js  c++  java
  • 数学思想方法-sasMEMO(17)

    SAS日期及时间格式

    data  _null_;
    input mydate YYMMDD10.;
    put mydate YYMMDDB10.;
    put mydate YYMMDDC10.;
    put mydate YYMMDDD10.;
    put mydate YYMMDDN8.;
    put mydate YYMMDDP10.;
    put mydate YYMMDDS10.;
    cards;
    2014-05-18
    ;
    run;

    本博客全部内容是原创,假设转载请注明来源

    http://blog.csdn.net/myhaspl/


    2014 05 18
    2014:05:18
    2014-05-18
    20140518
    2014.05.18
    2014/05/18
    NOTE: “DATA 语句”所用时间(总处理时间):
          实际时间          0.03 秒
          CPU 时间          0.01 秒

    短日期格式 

    data  _null_;
    input mydate YYMMDD10.;
    put mydate YYMMDDB8.;
    put mydate YYMMDDC8.;
    put mydate YYMMDDD8.;
    put mydate YYMMDDN7.;
    put mydate YYMMDDP8.;
    put mydate YYMMDDS8.;
    cards;
    2014-05-18
    ;
    run;

    14 05 18
    14:05:18
    14-05-18
     140518
    14.05.18
    14/05/18
    NOTE: “DATA 语句”所用时间(总处理时间):
          实际时间          0.00 秒
          CPU 时间          0.00 秒

    Writes SAS date values in the form <yy>yymmdd or <yy>yy-mm-dd, where the x in the format name is a character that represents the special character that separates the year, month, and day. The special character can be a hyphen (–), period (.), blank character, slash (/), colon (:), or no separator; the year can be either 2 or 4 digits.

    Syntax 




    YYMMDDxw. 






    Arguments 




    x




    identifies a separator or specifies that no separator appear between the year, the month, and the day. Here are the valid values: 




    B




    separates with a blank




    C




    separates with a colon 




    D




    separates with a hyphen 




    N




    indicates no separator




    P




    separates with a period 




    S




    separates with a slash.




    w




    specifies the width of the output field. 






    Default


    8






    Range


    2–10






    Interactions


    When w has a value of from 2 to 5, the date appears with as much of the year and the month. When w is 7, the date appears as a two-digit year without separators. 






    When x has a value of N, the width range is 2–8. 






    Details 




    The YYMMDDxw. format writes SAS date values in the form <yy>yymmdd or <yy>yyXmmXdd. Here is an explanation of the syntax: 




    <yy>yy




    is a two-digit or four-digit integer that represents the year. 




    X




    is a specified separator.




    mm




    is an integer that represents the month. 




    dd




    is an integer that represents the day of the month. 




    Comparisons 







    The YYMMDDw.d format is similar to the YYMMDDxw.d format, but YYMMDDxw.d format contains a separator between the year and month, such as a colon, slash, or period. 






    Example 




    The following examples use the input value of 18922, which is the SAS date value that corresponds to October 22, 2011. 










    Statements 




    Results 








     


    ----+----1----+ 






    a=put(18922,yymmddc5.); 


    11:10 






    a=put(18922,yymmddd8.); 


    11-10-22 






    a=put(18922,yymmddn8.); 


    20111022 






    a=put(18922,yymmddp10.); 


    2011.10.22 

    本博客全部内容是原创,假设转载请注明来源

    http://blog.csdn.net/myhaspl/


    data _null_;
    mydate=date();
    y=year(mydate);
    m=month(mydate);
    d=day(mydate);
    qtr=qtr(mydate);
    put mydate YYMMDD10.;
    put y;
    put m;
    put d;
    put qtr;
    mytime=time();
    put mytime TIME.;
    h=hour(mytime);
    mm=minute(mytime);
    put h;
    put mm;
    put "====";
    mydt=datetime();
    put mydt DATETIME21.;
    mm=minute(mydt);
    hh=hour(mydt);
    ss=second(mydt);
    put hh;
    put mm;
    put ss;
    run;
    输出
    2015-04-01
    2015
    4
    1
    2
    11:21:37
    11
    21
    ====
       01APR2015:11:21:37
    11
    21
    37.372999907

    -------------------------

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    互联网成为基础设施,数据成为生产资料,计算成为公共服务。让计算成为人类的能力,让数据成为世界的财富
    数据本没有价值,就像你留在地上的脚印,直到你有计算能力去处理才会产生价值。计算,如同其他基础设施一样,能够把沉寂的数据“沙子”变成经济、产业、财富的“金矿”。
    100多年前,铁路在美国成为基础设施,为美国带来翻天覆地的变化。今天互联网作为基础设施,对中国未来发展的推动绝对不会亚于当年铁路给美国带来的变化。
    HDU--1060
    素数
    欧几里德算法与扩展欧几里德算法
    HDU--1164
    挨踢人生路
    HDU题目分类
    HDU--2087
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4794879.html
Copyright © 2011-2022 走看看