Date 如何在SAS中查询日期
我需要将一些数据从SAS导出到CSV,以便将其移动到SQL Server并加载到其中。(服务器彼此看不见。) 数据中的字段具有以下定义:Date 如何在SAS中查询日期,date,sas,Date,Sas,我需要将一些数据从SAS导出到CSV,以便将其移动到SQL Server并加载到其中。(服务器彼此看不见。) 数据中的字段具有以下定义: 类型=数量 长度=8 格式=日期时间18 现在我只是想看看在一个日期范围内有多少条记录: proc sql; SELECT COUNT(*) FROM BNA_BASE.base_agent_bna_cust_date WHERE bna_outcome_ts >= '04Jun12:00:00:00'd AND bna_outcome_ts
- 类型=数量
- 长度=8
- 格式=日期时间18李>
proc sql;
SELECT COUNT(*)
FROM BNA_BASE.base_agent_bna_cust_date
WHERE bna_outcome_ts >= '04Jun12:00:00:00'd
AND bna_outcome_ts < '11Jun12:00:00:00'd
;
quit;
proc-sql;
选择计数(*)
从BNA_BASE.BASE_agent_BNA_cust_日期
其中bna_结果>='04Jun12:00:00:00'd
和bna_结果<'6月11日12:00:00'd
;
退出
但是我总是得到0
,尽管我可以在表中看到一些记录与我想查询的内容相匹配,例如06JUN12:12:42:57
有人能指出我愚蠢的错误吗?我应该用
dt
而不仅仅是d
WHERE bna_outcome_ts >= '04Jun12:00:00:00'dt
AND bna_outcome_ts < '11Jun12:00:00:00'dt
其中bna\u结果>='04Jun12:00:00:00'dt
和bna_结果<'6月11日12:00:00'dt
替代Dems答案的方法是使用datepart()函数
e、 g
where datepart(bna_outcome)>=“2012年6月4日”
和日期部分(bna_out come_ts)<'2012年6月11日'
where datepart(bna_outcome_ts) >= '04jun2012'd
and datepart(bna_outcoume_ts) < '11jun2012'd