Help using Base SAS procedures

Year Function in Proc Sql

Accepted Solution Solved
Reply
Regular Contributor
Posts: 195
Accepted Solution

Year Function in Proc Sql

Hi All,

I stuck at one place where i am getting remerging note like this -

NOTE: The query requires remerging summary statistics back with the original data.

You can view the data in attachment and syntax below

proc

sql

;

Here year function is not working in where clause.

create

table neworder

as

select

a.orderid,sum(b.UnitPrice * b.Quantity) as

Sales

from

data.orders as

a,

data.Order_details

as

b

where

a.orderid=b.orderid

and

year(orderdate) = 1996

;

quit

;

Attachment
Attachment

Accepted Solutions
Solution
‎03-15-2012 03:19 PM
Super User
Posts: 17,898

Year Function in Proc Sql

Orderdate is a DATETIME field, not a date. so you need to get the datepart first and then the year

ie. year(datepart(orderdate))=1996 

View solution in original post


All Replies
Solution
‎03-15-2012 03:19 PM
Super User
Posts: 17,898

Year Function in Proc Sql

Orderdate is a DATETIME field, not a date. so you need to get the datepart first and then the year

ie. year(datepart(orderdate))=1996 

Regular Contributor
Posts: 195

Year Function in Proc Sql

Thanks for getting me.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 1180 views
  • 0 likes
  • 2 in conversation