BookmarkSubscribeRSS Feed
deleted_user
Not applicable
My ultimate goal is to append 2 data sets. The base data set has 2 dates that have the format datetime22.3 These dates look like 01OCT2007:00:00:00:000
The data set to be appended has the same date fields but they are formatted as $24. They look like this: 2007/11/01:12:00:00 AM

All column names in both tables are the same, but some differ in length and type. When I use proc append with force, the dates that come from the second data set are missing after the append.

I have tried this:
Admission_date = put(input(txtAdmission_date,AnyDtDTm11.), datetime22.3);
This gives me 01NOV2007:00:00:00:000, but the format is still $22 rather than datetime22.3

The original table was pulled from a SQL server data base using proc sql. The second table was imported from a .csv file into a dataset.

Thanks for any help.

Message was edited by: pk

Message was edited by: pk Message was edited by: pk
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Your objective here should be to have SAS DATETIME variables (not DATE variables for clarification), as explained in your post. Consider that SAS stores DATETIME type variables as numeric representing seconds since 01JAN1960:00:00:00. A SAS DATE variable, a SAS numeric variable as well, represents days since 01JAN1960.

So, you should not want to do a PUT at all, with your conversion code, only the INPUT to convert the character string to a SAS DATETIME numeric variable value. Instead, perform your INPUT function, and also assign a SAS DATETIME FORMAT statement to the variable you are converting from character-format to numeric.

Have a look at the SAS DOCUMENTATION on the SAS support website, where the topic about SAS DATE and DATETIME variables is discussed extensively -- URL link is http://support.sas.com/ for reference.

Scott Barry
SBBWorks,Inc.
deleted_user
Not applicable
Thanks for the help. That did it.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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