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

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

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

数学思想方法-sasMEMO(17)的更多相关文章

  1. 数学思想方法-分布式计算-linux/unix技术基础(3)

    夹: ~表示当前用户的主文件夹 .它代表了当前文件夹 ..它代表的父文件夹 链接文件 使用不同的文件名指的是相同的数据或程序.硬链接 在相同的物理文件系统,创建一个硬链接 -bash-4.2$ fin ...

  2. 数学思想方法-分布式计算-linux/unix技术基础(5)

    shell命令行参数 -bash-4.2$ cat test1.sh#!/bin/shecho "$0  "echo "$1  "echo "$2   ...

  3. 数学思想方法-python计算战(8)-机器视觉-二值化

    二值化 hreshold Applies a fixed-level threshold to each array element. C++: double threshold(InputArray ...

  4. 数学思想:为何我们把 x²读作x平方

    要弄清楚这个问题,我们得先认识一个人.古希腊大数学家 欧多克索斯,其在整个古代仅次于阿基米德,是一位天文学家.医生.几何学家.立法家和地理学家. 为何我们把 x²读作x平方呢? 古希腊时代,越来越多的 ...

  5. pandas学习(常用数学统计方法总结、读取或保存数据、缺省值和异常值处理)

    pandas学习(常用数学统计方法总结.读取或保存数据.缺省值和异常值处理) 目录 常用数学统计方法总结 读取或保存数据 缺省值和异常值处理 常用数学统计方法总结 count 计算非NA值的数量 de ...

  6. 21.1 Math(数学运算)方法使用 、工具类

    package day21_static.meathDemo; //Math: 包含一些基本的数学运算方法 //从api中搜Math,它都用的static修饰. public class MethDe ...

  7. js中数组、字符串、日期、数学API方法一览

    以下内容摘选自 http://www.w3school.com.cn/jsref/jsref_obj_array.asp 点击方法新窗口打开详解 数组: 方法 描述 concat() 连接两个或更多的 ...

  8. HDU 4635 Strongly connected(强连通分量缩点+数学思想)

    题意:给出一个图,如果这个图一开始就不是强连通图,求出最多加多少条边使这个图还能保持非强连通图的性质. 思路:不难想到缩点转化为完全图,然后找把它变成非强连通图需要去掉多少条边,但是应该怎么处理呢…… ...

  9. numpy学习笔记 - numpy常用函数、向量化操作及基本数学统计方法

    # -*- coding: utf-8 -*-"""主要记录代码,相关说明采用注释形势,供日常总结.查阅使用,不定时更新.Created on Fri Aug 24 19 ...

随机推荐

  1. 用golang写的 分解x86 intel boot/recovery工具

    源代码地址: https://github.com/sndnvaps/pack-unpack-intel

  2. Java反射探索研究(转)

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankakay 摘要:本文详细深入讲解是Java中反射的机制,并介绍了如何通过反射来生成对象.调用函数.取得 ...

  3. 【原创翻译】认识MVC设计模式:web应用开发的基础(实际编码篇)

    原文地址:http://www.larryullman.com/2009/10/15/understanding-mvc-part-3/ 全系列INDEX [原创翻译]认识MVC设计模式:web应用开 ...

  4. 在C#环境中动态调用IronPython脚本(一)

    本文讲述用C#调用Ironpython运行环境,解析并运行动态pyhton脚本.这种情况应用在那些需要滞后规定行为的场合,例如,动态计算项(计算引擎),用户可以自定义计算内容.计算公式等. 本文的代码 ...

  5. php xss过滤

    XSS已知CSS (Cross Site Script) ,跨站点脚本攻击.它指的是恶意攻击者Web插入恶意网页html代码,当用户浏览网页.其中嵌入Web里面html代码运行,从而实现了一些人的攻击 ...

  6. CAS Spring Security 3 整合配置(转)

    一般来说, Web 应用的安全性包括用户认证( Authentication )和用户授权( Authorization )两个部分.用户认证指的是验证某个用户是否为系统中的合法主体,也就是说用户能否 ...

  7. 取缔Chrome装载电脑管家的广告过滤脚本代码

    今天Chrome调试脚本.加载在下面的脚本中找到的内容: /* 电脑管家chrome 广告过滤 */ var GJAD_CS = { elemhideElt : null, setElemhideCS ...

  8. Directx11学习笔记【十】 画一个简单的三角形

    本篇笔记要实现的是在屏幕上渲染出一个三角形,重点要学习的是渲染一个几何体的流程方式. 为了渲染几何图形,需要一个顶点缓存和一个描述顶点布局的输入层,还有着色器(主要是顶点着色器和像素着色器),下面来看 ...

  9. shell 脚本运算符

    1.数值 格式: test "num1" opr "num2" [ "num1" opr "num2" ] opr 取值 ...

  10. ListView的操作模式的选择的更详细的解释CHOICE_MODE_MULTIPLE与CHOICE_MODE_MULTIPLE_MODAL

    本文介绍了我们将如何取得具体ListView多选择操作.本文将正确使用ListViewCHOICE_MODE_MULTIPLE要么CHOICE_MODE_MULTIPLE_MODAL时间easy误区. ...