Path to mathematics-sas memo (16)

Source: Internet
Author: User
Tags month name
Data_null _; mydate7MAR13d; Primary; putmydateYYMMDDS10.; putmydateYYMMDD10.; putmydateWEEKDATE.; putmydateWORDDATE.; run; 2013.03.072013072013: 03: 07201303072013-

Data _ null _; mydate = 7MAR13d; put mydate YYMMDDP10.; put mydate YYMMDDN8.; put mydate YYMMDDC10.; put mydate YYMMDDS10.; put mydate YYMMDD10.; put mydate WEEKDATE .; put mydate WORDDATE .; run; 2013.03.07 20130307 2013-

Data _ null _;

Mydate = '7mar13 'd;

Put mydate YYMMDDP10 .;

Put mydate YYMMDDN8 .;

Put mydate YYMMDDC10 .;

Put mydate YYMMDDS10 .;

Put mydate YYMMDD10 .;

Put mydate WEEKDATE .;

Put mydate WORDDATE .;

Run;

2013.03.07

20130307

June

2013-03-07

Thursday, March 7, 2013

March 7, 2013

NOTE: time used by the "DATA statement" (total processing time ):

Actual Time: 0.01 seconds

CPU time: 0.01 seconds

====================

Data _ null _;

Mytime = '17: 25: 38 't;

Put mytime HHMM .;

Put mytime TIME .;

Put mytime TIMEAMPM .;

Put mytime HOUR .;

Put mytime Todd .;

Run;

17: 26

17:25:38

5:25:38

17

17:25:38

Data _ null _;

Now = datetime ();

Put now DATEAMPM .;

Put now DATETIME .;

Put now nldatm .;

Run;

30MAR15: 03: 12: 14 PM

30MAR15: 15: 12: 14

, January 1, March 30, 2015

Data _ null _;

Now = date ();

Put now YEAR .;

Put now MONTH .;

Put now DAY .;

Run;

2015

3

30

NOTE: time used by the "DATA statement" (total processing time ):

Actual Time: 0.00 seconds

CPU time: 0.00 seconds

Data _ null _;

/* Current date and time */

Now = date ();

Put now YEAR .;

Put now MONTH .;

Put now DAY .;

Put now = nldate .;

T1 = time ();

Put t1 = time .;

Put t1 = nltimap15 .;

D1 = today ();

Put d1 = nldate .;

D2 = today ();

Put d2 = nldate .;

Run;

2015

3

30

Now = March 30, 2015

T1 = 15:21:50

T1 = 03:21:50 pm

D1 = January 1, March 30, 2015

D2 = March 30, 2015

NOTE: time used by the "DATA statement" (total processing time ):

Actual Time: 0.01 seconds

CPU time: 0.01 seconds

Writes datetime values in the form ddmmmyy: hh: mm: ss. ss.

Category: Date and Time
Alignment: Right
Restriction: If w-d <17, SAS truncates the decimal values.
Interaction: When the DECIMALCONV = system option is set to STDIEEE, the output that is written using this format might differ slightly from previous releases. for more information, see DECIMALCONV = System Option in SAS System Options: Reference.

SyntaxDATETIMEw. d
Syntax Descriptionw

Specifies the width of the output field.

Default 16
Range 7-40
Tip SAS requires a minimum w value of 16 to write a SAS datetime value with the date, hour, and seconds. add an additional two places to w and a value to d to return values with optional decimal fractions of seconds.
D

Specifies the number of digits to the right of the decimal point in the seconds value. This argument is optional.

Range 0-39
Requirement Must be less than w
DetailsThe DATETIMEw. d format writes SAS datetime values in the form ddmmmyy: hh: mm: ss. ss: ddis an integer that represents the day of the month. mmm is the first three letters of the month name. yyis a two-digit integer that represents the year. hhis an integer that represents the hour in 24-hour clock time. mmis an integer that represents the minutes. ss. ssis the number of seconds to two decimal places. exampleThe example table uses the input value of 1668138559, which is the SAS datetime value that corresponds to 3:49:19 a.m. on November 10,201 2.
SAS Statement Result
----+----1----+----2----+
put event datetime.;
10NOV12:03:49:19
put event datetime7.;
10NOV12
put event datetime12.;
  10NOV12:03
put event datetime18.;
  10NOV12:03:49:19
put event datetime18.1;
10NOV12:03:49:19.0
put event datetime19.;
 10NOV2012:03:49:19
put event datetime20.1;
10NOV2012:03:49:19.0
put event datetime21.2;
10NOV2012:03:49:19.00
====================================== Data _ null _;
Run;

30MAR2015: 17: 25: 51.91

====================

DATETIMEw. Timeout

SyntaxDATETIMEw. Syntax Descriptionw

Specifies the width of the input field.

Default 18
Range 13-40
DetailsThe 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. mmmis the first three letters of the month name. yy or yyyyis a two-digit or four-digit integer that represents the year. hh is an integer between 00 and 23 that represents hours. mmis 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. comparisonsThe DATETIMEw. d Required 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 forma [from the Internet (http://www.68idc.cn)] t 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 contains 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

Writes SAS date values in the form Yymmdd or Yy-mm-dd, where a hyphen is the separator and the year appears as either 2 or 4 digits.

YYMMDDw. Argumentsw

Specifies the width of the output field.

Default 8
Range 2-10
Interaction When w has a value of from 2 to 5, the date appears with as much of the year and the month as possible. when w is 7, the date appears as a two-digit year without hyphens.
DetailsThe YYMMDDw. format writes SAS date values in the form Yymmdd or Yy-mm-dd. Here is an explanation of the syntax: Yyis a two-digit or four-digit integer that represents the year. -is the separator. mmis an integer that represents the month. ddis an integer that represents the day of the month. comparisonsThe YYMMDDw. d format is similar to the YYMMDDxw. d format, cipher t the YYMMDDxw. d format contains separators, such as a colon, slash, or period between the year, month, and day. exampleThe following examples use the input value of 18720, which is the SAS date value that corresponds to limit L 3, 2011.
Statements Results
 
----+----1----+
a=put(18720,yymmdd2.);
11
a=put(18720,yymmdd3.);
11
a=put(18720,yymmdd4.);
1104
a=put(18720,yymmdd5.);
11-04
a=put(18720,yymmdd6.);
110403
a=put(18720,yymmdd7.);
110403
a=put(18720,yymmdd8.);
11-04-03
a=put(18720,yymmdd10.);
2011-04-03
======================================

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.