0

0

数学之路-sas备忘(16)

php中文网

php中文网

发布时间:2016-06-07 16:13:18

|

1703人浏览过

|

来源于php中文网

原创

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:03:07 2013/03/07 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

2013:03:07

2013/03/07

2013-03-07

      Thursday, March 7, 2013

     March 7, 2013

NOTE: “DATA 语句”所用时间(总处理时间):

      实际时间          0.01 秒

      CPU 时间          0.01 秒

 

a0.dev
a0.dev

专为移动端应用开发设计的AI编程平台

下载

 

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

 

data _null_;

mytime ='17:25:38't;

put mytime HHMM.;

put mytime TIME.;

put mytime TIMEAMPM.;

put mytime HOUR.;

put mytime TOD.;

run;

 

 

 

 

 

 

 

 

 

17:26

17:25:38

 5:25:38 PM

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

2015年03月30日 15时12分14秒

 

 

 

 

 

data _null_;

now=date();

put now YEAR.;

put now MONTH.;

put now DAY.;

run;

 

2015

 3

30

NOTE: “DATA 语句”所用时间(总处理时间):

      实际时间          0.00 秒

      CPU 时间          0.00 秒

 

 

 

data _null_;

/*当前日期及时间*/

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=2015年03月30日

t1=15:21:50

t1=下午03:21:50

d1=2015年03月30日

d2=2015年03月30日

NOTE: “DATA 语句”所用时间(总处理时间):

      实际时间          0.01 秒

      CPU 时间          0.01 秒

 

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

Category: Date and Time
Alignment: Right
Restriction: If w–d
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.

Syntax

DATETIMEw.d
Syntax Description

w

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

Details

The 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.

Example

The 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, 2012.
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. Informat


 

 

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. 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.

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 forma【本文来自鸿网互联 (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 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

 

\

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.

Arguments

w

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.

Details

The 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.

Comparisons

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

Example

The following examples use the input value of 18720, which is the SAS date value that corresponds to April 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
========================

 

相关专题

更多
Golang gRPC 服务开发与Protobuf实战
Golang gRPC 服务开发与Protobuf实战

本专题系统讲解 Golang 在 gRPC 服务开发中的完整实践,涵盖 Protobuf 定义与代码生成、gRPC 服务端与客户端实现、流式 RPC(Unary/Server/Client/Bidirectional)、错误处理、拦截器、中间件以及与 HTTP/REST 的对接方案。通过实际案例,帮助学习者掌握 使用 Go 构建高性能、强类型、可扩展的 RPC 服务体系,适用于微服务与内部系统通信场景。

8

2026.01.15

公务员递补名单公布时间 公务员递补要求
公务员递补名单公布时间 公务员递补要求

公务员递补名单公布时间不固定,通常在面试前,由招录单位(如国家知识产权局、海关等)发布,依据是原入围考生放弃资格,会按笔试成绩从高到低递补,递补考生需按公告要求限时确认并提交材料,及时参加面试/体检等后续环节。要求核心是按招录单位公告及时响应、提交材料(确认书、资格复审材料)并准时参加面试。

44

2026.01.15

公务员调剂条件 2026调剂公告时间
公务员调剂条件 2026调剂公告时间

(一)符合拟调剂职位所要求的资格条件。 (二)公共科目笔试成绩同时达到拟调剂职位和原报考职位的合格分数线,且考试类别相同。 拟调剂职位设置了专业科目笔试条件的,专业科目笔试成绩还须同时达到合格分数线,且考试类别相同。 (三)未进入原报考职位面试人员名单。

58

2026.01.15

国考成绩查询入口 国考分数公布时间2026
国考成绩查询入口 国考分数公布时间2026

笔试成绩查询入口已开通,考生可登录国家公务员局中央机关及其直属机构2026年度考试录用公务员专题网站http://bm.scs.gov.cn/pp/gkweb/core/web/ui/business/examResult/written_result.html,查询笔试成绩和合格分数线,点击“笔试成绩查询”按钮,凭借身份证及准考证进行查询。

11

2026.01.15

Java 桌面应用开发(JavaFX 实战)
Java 桌面应用开发(JavaFX 实战)

本专题系统讲解 Java 在桌面应用开发领域的实战应用,重点围绕 JavaFX 框架,涵盖界面布局、控件使用、事件处理、FXML、样式美化(CSS)、多线程与UI响应优化,以及桌面应用的打包与发布。通过完整示例项目,帮助学习者掌握 使用 Java 构建现代化、跨平台桌面应用程序的核心能力。

65

2026.01.14

php与html混编教程大全
php与html混编教程大全

本专题整合了php和html混编相关教程,阅读专题下面的文章了解更多详细内容。

36

2026.01.13

PHP 高性能
PHP 高性能

本专题整合了PHP高性能相关教程大全,阅读专题下面的文章了解更多详细内容。

75

2026.01.13

MySQL数据库报错常见问题及解决方法大全
MySQL数据库报错常见问题及解决方法大全

本专题整合了MySQL数据库报错常见问题及解决方法,阅读专题下面的文章了解更多详细内容。

21

2026.01.13

PHP 文件上传
PHP 文件上传

本专题整合了PHP实现文件上传相关教程,阅读专题下面的文章了解更多详细内容。

35

2026.01.13

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
Node.js 教程
Node.js 教程

共57课时 | 8.6万人学习

CSS3 教程
CSS3 教程

共18课时 | 4.6万人学习

Rust 教程
Rust 教程

共28课时 | 4.4万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号