New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
titanbob
Calcite | Level 5

I'm trying to concatenate 4 data elements together to create a unique ID, the last data element is a date. When I use the CATS function, it is converting the date into the numeric equivalent and that's not what I want. I want the actual date 

cats(a.agreement_type,a.customer_number,a.trade_number,a.maturity_date). What do I need to do for the date?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Yeah, this is a common gotcha. SAS will convert numeric using the BEST format which puts it in as a number, not the date. You need to use PUT() to convert it to the format desired as shown in BallardW code.

View solution in original post

3 REPLIES 3
ballardw
Super User

@titanbob wrote:

I'm trying to concatenate 4 data elements together to create a unique ID, the last data element is a date. When I use the CATS function, it is converting the date into the numeric equivalent and that's not what I want. I want the actual date 

cats(a.agreement_type,a.customer_number,a.trade_number,a.maturity_date). What do I need to do for the date?

 

Thanks


Possibly something like

 

cats(a.agreement_type,a.customer_number,a.trade_number, put(a.maturity_date, date9.) ).

if you want the date to appear like 20OCT2018 if the value is an actual SAS date value. Pick the format you want in place of date9 .

 

Reeza
Super User
Yeah, this is a common gotcha. SAS will convert numeric using the BEST format which puts it in as a number, not the date. You need to use PUT() to convert it to the format desired as shown in BallardW code.
titanbob
Calcite | Level 5

Thanks for the help, really appreciate it!!!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 2950 views
  • 2 likes
  • 3 in conversation