Help using Base SAS procedures

Compare two columns in the same table

Reply
Occasional Contributor
Posts: 11

Compare two columns in the same table

Hi,

I am new to SAS and I want to compare the below fields in the same table

Please let me know how to compare the two different datatype ?

 

Sr_date  mentioned as varchar_type

dt_date mentioned as date_type

 

Example

 

sr_date                                          dt_date

10/05/2014 14:01:18                     2014-10-05

 

Date values should be same in both fields .if anyting mismatched, query should pick the unmatched record

Please let me know how to write a query for the above scenario?

 

Super User
Posts: 7,757

Re: Compare two columns in the same table

if dt_date = input(substr(sr_date,1,10),ddmmyy10.) then do .....

BTW, SAS only knows two data types, character and numeric.

'SAS dates' are numeric values containing the number of days since 01/01/1960 and having one of the date formats assigned.

There are no varchar variables in SAS, only fixed length character.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 11,335

Re: Compare two columns in the same table

Are you working with a SAS dataset or an external database? If the later you may have to specify which as there are some gotcha's depending.

Ask a Question
Discussion stats
  • 2 replies
  • 537 views
  • 0 likes
  • 3 in conversation