BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have been exploring the best way to convert numeric dates in the form 19990125 (YYYYMMDD) to SAS date values.

So far, I have come up with the following solution:
For numeric dates in the form 20050101 (YYYYMMDD): input(put(TABLE.DATE_COL ,8.),YYMMDD10.)
For numeric dates in the form 200501 (YYYYMM): input(put(TABLE.DATE_COL ,6.)||'01',YYMMDD10.)

Does anyone know of a better/more efficient way of doing this? Many dates from oracle or db2 come in this format and as often as SAS imports data from these dbms, I would think there is a better way.

Thanks in advance.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Recommend searching the SAS support http://support.sas.com/ website - here is a useful Google advanced search argument which yielded some DOC and technical/conference reference matches:

converting oracle dates site:sas.com


Scott Barry
SBBWorks, Inc.
Patrick
Opal | Level 21
I believe SAS does a pretty good job in converting dates from a DBMS.
But if the dates in the DMBS are stored as characters - well: then you store them as well as characters in SAS or you tell SAS how to convert these characters.

Only because there are digits in this character columns doesn't make it numeric (anyway in most DBMS there are special types for dates).

But what about this:
data _null_;
chardate='20050912';
numdate=input(chardate,yymmdd8.);
put numdate yymmdds10.;

chardate='200509';
numdate=input(chardate,yymmn6.);
put numdate yymms7.;

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 802 views
  • 0 likes
  • 3 in conversation