IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]数学之路-sas备忘(15)

    u010255642发表于 2015-03-28 16:10:48
    love 0

    sas日期格式

    DATETIMEw. Informat



    Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss.


    Syntax


    DATETIMEw.
    Syntax Description


    w


    specifies the width of the input field.
    Default 18
    Range 13–40
    Details


    The datetime values must be in the following form: ddmmmyy or ddmmmyyyy, followed by a blank or special character, followed by hh:mm:ss.ss (the time):
    dd
    is an integer between 01 and 31 that represents the day of the month.
    mmm
    is the first three letters of the month name.
    yy or yyyy
    is a two-digit or four-digit integer that represents the year.
    hh
    is an integer between 00 and 23 that represents hours.
    mm
    is an integer between 00 and 59 that represents minutes.
    ss.ss
    is the number of seconds ranging from 00–59 with the fraction of a second following the decimal point.
    DATETIMEw. requires values for both the date and the time. However, the ss.ss portion is optional.
    Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
    Note: SAS can read time values with AM and PM in them.
    Comparisons


    The DATETIMEw.d informat reads datetime values with optional separators in the form dd-mmm-yy hh:mm:ss.ss AM|PM, and the date and time can be separated by a special character.
    The MDYAMPMw.d in format reads datetime values with optional separators in the form mm-dd-yy
    hh:mm:ss.ss AM | PM, and requires a space between the date and the time.
    The YMDDTTMw.d informat reads datetime values with required separators in the form
    yy-mm-dd/hh:mm:ss.ss.
    Example


    input date_and_time datetime20.;
    Data Line
    Result
    ----+----1----+----2
    16mar12:11:23:07.4
    1647516187.4
    16mar2012/11:23:07.4
    1647516187.4
    16mar2012/11:23 PM
    1647559380.0


    DATETIMEw. Informat




    Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss.




    Syntax




    DATETIMEw.
    Syntax Description




    w




    specifies the width of the input field.
    Default 18
    Range 13–40
    Details




    The datetime values must be in the following form: ddmmmyy or ddmmmyyyy, followed by a blank or special character, followed by hh:mm:ss.ss (the time):
    dd
    is an integer between 01 and 31 that represents the day of the month.
    mmm
    is the first three letters of the month name.
    yy or yyyy
    is a two-digit or four-digit integer that represents the year.
    hh
    is an integer between 00 and 23 that represents hours.
    mm
    is an integer between 00 and 59 that represents minutes.
    ss.ss
    is the number of seconds ranging from 00–59 with the fraction of a second following the decimal point.
    DATETIMEw. requires values for both the date and the time. However, the ss.ss portion is optional.
    Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
    Note: SAS can read time values with AM and PM in them.
    Comparisons




    The DATETIMEw.d informat reads datetime values with optional separators in the form dd-mmm-yy
    hh:mm:ss.ss AM|PM, and the date and time can be separated by a special character.
    The MDYAMPMw.d in format reads datetime values with optional separators in the form mm-dd-yy
    hh:mm:ss.ss AM | PM, and requires a space between the date and the time.
    The YMDDTTMw.d informat reads datetime values with required separators in the form
    yy-mm-dd/hh:mm:ss.ss.
    Example



    本博客所有内容是原创,如果转载请注明来源

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


    input date_and_time datetime20.;
    Data Line
    Result
    ----+----1----+----2
    16mar12:11:23:07.4
    1647516187.4
    16mar2012/11:23:07.4
    1647516187.4
    16mar2012/11:23 PM
    1647559380.0
    DATETIMEw. Informat


    Reads datetime values in the form ddmmmyy hh:mm:ss.ss or ddmmmyyyy hh:mm:ss.ss.


    Syntax


    DATETIMEw.
    Syntax Description


    w


    specifies the width of the input field.
    Default 18
    Range 13–40
    Details


    The datetime values must be in the following form: ddmmmyy or ddmmmyyyy, followed by a blank or special character, followed by hh:mm:ss.ss (the time):
    dd
    is an integer between 01 and 31 that represents the day of the month.
    mmm
    is the first three letters of the month name.
    yy or yyyy
    is a two-digit or four-digit integer that represents the year.
    hh
    is an integer between 00 and 23 that represents hours.
    mm
    is an integer between 00 and 59 that represents minutes.
    ss.ss
    is the number of seconds ranging from 00–59 with the fraction of a second following the decimal point.
    DATETIMEw. requires values for both the date and the time. However, the ss.ss portion is optional.
    Note: SAS interprets a two-digit year as belonging to the 100-year span that is defined by the YEARCUTOFF= system option.
    Note: SAS can read time values with AM and PM in them.
    Comparisons


    The DATETIMEw.d informat reads datetime values with optional separators in the form dd-mmm-yy
    hh:mm:ss.ss AM|PM, and the date and time can be separated by a special character.
    The MDYAMPMw.d in format reads datetime values with optional separators in the form mm-dd-yy
    hh:mm:ss.ss AM | PM, and requires a space between the date and the time.
    The YMDDTTMw.d informat reads datetime values with required separators in the form
    yy-mm-dd/hh:mm:ss.ss.
    Example


    input date_and_time datetime20.;
    Data Line
    Result
    ----+----1----+----2
    16mar12:11:23:07.4
    1647516187.4
    16mar2012/11:23:07.4
    1647516187.4
    16mar2012/11:23 PM

    1647559380.0


    DATEw. Format


    Writes date values in the form ddmmmyy, ddmmmyyyy, or dd-mmm-yyyy.






    Category:


    Date and Time






    Alignment:


    Right






    Syntax


    Syntax Description


    Details


    Example


    See Also




    Syntax




    DATEw.






    Syntax Description




    w




    specifies the width of the output field.






    Default


    7






    Range


    5–11






    Tip


    Use a width of 9 to print a four-digit year without a separator between the day, month, and year. Use a width of 11 to print a four-digit year using a hyphen as a separator between the day, month, and year






    Details




    The DATEw. format writes SAS date values in the form ddmmmyy, ddmmmyyyy, or dd-mmm-yyyy, where




    dd




    is an integer that represents the day of the month.




    mmm




    is the first three letters of the month name.




    yy or yyyy




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




    Example




    The example table uses the input value of 19068, which is the SAS date value that corresponds to March 16, 2012.










    SAS Statement




    Result














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






    put day date5.;


    16MAR






    put day date6.;


    16MAR






    put day date7.;


    16MAR12






    put day date8.;


    16MAR12






    put day date9.;


    16MAR2012






    put day date11.;


    16-MAR-2012

    本博客所有内容是原创,如果转载请注明来源

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



    Task
    Type of Language Element
    Language Element
    Input
    Result
    Write SAS date values in recognizable forms
    Date formats
    DATE.
    19434
    17MAR13
    DATE9.
    19434
    17MAR2013
    DAY.
    19434
    17
    DDMMYY.
    19434
    17/03/13
    DDMMYY10.
    19434
    17/03/2013
    DDMMYYB.
    19434
    17 03 13
    DDMMYYB10.
    19434
    17 03 2013
    DDMMYYC.
    19434
    17:03:13
    DDMMYYC10.
    19434
    17:03:2013
    DDMMYYD.
    19434
    17-03-13
    DDMMYYD10.
    19434
    17-03-2013
    DDMMYYN.
    19434
    17032013
    DDMMYYN6.
    19434
    170313
    DDMMYYP.
    19434
    17.03.13
    DDMMYYP10.
    19434
    17.03.2013
    DDMMYYS.
    19434
    17/03/13
    DDMMYYS10.
    19434
    17/03/2013
    DOWNAME.
    19434
    Sunday
    JULDAY. 1
    19434
    76
    JULIAN. 1
    19434
    13076
    MMDDYY.
    19434
    03/17/13
    MMDDYY10.
    19434
    03/17/2013
    MMDDYYB.
    19434
    03 17 13
    MMDDYYB10.
    19434
    03 17 2013
    MMDDYYC.
    19434
    03:17:13
    MMDDYYC10.
    19434
    03:17:2013
    MMDDYYD.
    19434
    03-17-13
    Write SAS date values in recognizable forms
    Date formats
    MMDDYYD10.
    19434
    03-17-2013
    MMDDYYN.
    19434
    03172013
    MMDDYYN8.
    19434
    03172013
    MMDDYYP.
    19434
    03.17.13
    MMDDYYP10.
    19434
    03.17.2013
    MMDDYYS.
    19434
    03/17/13
    MMDDYYS10.
    19434
    03/17/2013
    MMYY.
    19434
    03M2013
    MMYYC.
    19434
    03:2013
    MMYYD.
    19434
    03-2013
    MMYYN.
    19434
    032013
    MMYYP.
    19434
    03.2013
    MMYYS.
    19434
    03/2013
    MONNAME.
    19434
    March
    MONTH.
    19434
    3
    MONYY.
    19434
    MAR13
    PDJULG. 1
    19434
    2013076F
    PDJULI. 1
    19434
    0100076F
    WEEKDATE.
    19434
    Sunday, March 17, 2013
    WEEKDAY.
    19434
    1
    WORDDATE.
    19434
    March 17, 2013
    WORDDATX.
    19434
    17 March 2013
    Quarter formats
    QTR.
    19434
    1
    QTRR.
    19434
    I
    Time formats
    TIME.
    19434
    5:23:54
    TIMEAMPM.
    19434
    5:23:54 AM
    TOD.
    19434
    05:23:54
    Write SAS date values in recognizable forms
    Year formats
    YEAR.
    19434
    2013
    YYMM.
    19434
    2013M03
    YYMMC.
    19434
    2013:03
    YYMMD.
    19434
    2013-03
    YYMMP.
    19434
    2013.03
    YYMMS.
    19434
    2013/03
    YYMMN.
    19434
    201303
    YYMMDD.
    19434
    13-03-17
    YYMON.
    19434
    2013MAR
    Year/Quarter formats
    YYQ.
    19434
    2013Q1
    YYQC.
    19434
    2013:1
    YYQD.
    19434
    2013-1
    YYQP.
    19434
    2013.1
    YYQS.
    19434
    2013/1
    YYQN.
    19434
    20131
    YYQR.
    19434
    2013QI
    YYQRC.
    19434
    2013:I
    YYQRD.
    19434
    2013-I
    YYQRP.
    19434
    2013.I
    YYQRS.
    19434
    2013/I
    YYQRN.
    19434
    2013I
    1In SAS, a Julian date is a date in the form YYNNN or YYYYNNN, where YY is a two-digit year, YYYY is a four-digit year, and NNN is the ordinal offset from January 1 of the year YY or YYYY. SAS processes Julian dates only for valid SAS dates.
    Tasks with Dates and Times, Part 2
    Task
    Type of Language Element
    Language Element
    Input
    Result
    Date Tasks
    Read calendar dates as SAS date
    Note: YEARCUTOFF=1926
    Date informats
    DATE.
    17MAR13
    19434
    DATE9.
    17MAR2013
    19434
    DDMMYY.
    170313
    19434
    DDMMYY8.
    17032013
    19434
    JULIAN. 1
    13076
    19434
    JULIAN7. 1
    2013077
    19434
    MMDDYY.
    031713
    19434
    MMDDYY8.
    03172013
    19434
    MONYY.
    MAR13
    19418
    YYMMDD.
    130317
    19434
    YYMMDD8.
    20130317
    19434
    YYQ.
    13q1
    19359
    DATETIME
    17MAR2013 00:00:00
    1679097600
    TIME
    14:45:32
    53132
    Return today's date as a SAS date value
    Date functions
    DATE() or TODAY() (equivalent)
    ( )
    The SAS date value for today.
    Extract calendar dates from SAS
    Date functions
    DAY
    19434
    17
    HOUR
    19434
    5
    JULDATE 1
    19434
    13076
    JULDATE7 1
    19434
    2013076
    MINUTE
    19434
    23
    MONTH
    19434
    3
    QTR
    19434
    1
    SECOND
    19434
    54
    WEEKDAY
    19434
    1
    YEAR
    19434
    2013
    Write a date as a constant in an expression
    SAS date constant
    'ddmmmyy'd
    or
    'ddmmmyyyy'd
    '17mar13'd
    '17mar2013'd
    19434
    Write today's date as a string
    SYSDATE automatic macro variable
    SYSDATE
    &SYSDATE;
    The date at the time of SAS initialization in the form DDMMMYY.
    SYSDATE9
    SYSDATE9
    &SYSDATE9;
    The date at time of SAS initialization, in the form DDMMMYYYY.
    Time Tasks
    Write SAS time values as time values
    time formats
    HHMM.
    19434
    5:24
    HOUR.
    19434
    5
    MMSS.
    19434
    323
    TIME.
    19434
    5:23:54
    TIMEAMPM.
    19434
    5:23:54 AM
    TOD.
    19434
    05:23:54
    Read time values as SAS time values
    Time informats
    TIME.
    05:23:54
    19434
    Write the current time as a string
    SYSTIME automatic macro variable
    SYSTIME
    &SYSTIME;
    The time at the moment of execution, in the form HH:MM
    Return the current time of day as a SAS time value
    Time functions
    TIME( )
    ( )
    The SAS time value at moment of execution, in the form NNNNN.NNN.
    Return the time part of a SAS datetime value
    Time functions
    TIMEPART
    17mar2013 05:11:43
    5:11:43
    Datetime Tasks
    Write SAS datetime values as datetime values
    Datetime formats
    DATEAMPM
    1679097600
    17MAR13:12:00:00 AM
    DATETIME
    1679097600
    17MAR13:00:00:00
    Read datetime values as SAS datetime values
    Datetime informats
    DATETIME
    17MAR13:00:00:00
    1679097600
    Return the current date and time of day as a SAS datetime value
    Datetime functions
    DATETIME()
    ()
    The SAS datetime value at the moment of execution, in the form NNNNNNNNNN.N.
    Interval Tasks
    Return the number of specified time intervals that lie between the two date or datetime values
    Interval functions
    INTCK
    week2
    01aug60
    01jan13
    1368
    Advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value
    Interval functions
    INTNX
    day
    17mar12
    365
    19434
    1In SAS, a Julian date is a date in the form YYNNN or YYYYNNN, where YY is a two-digit year, YYYY is a four-digit year, and NNN is the ordinal offset from January 1 of the year YY or YYYY. SAS processes Julian dates only for valid SAS dates.



沪ICP备19023445号-2号
友情链接