BookmarkSubscribeRSS Feed
Calcite | Level 5

In SAS 9.2, when i read a text file using proc import to bring as a SAS dataset, one of the column which had date value [2015/08/13:12:00:00 AM] used to be imported as character format and the date value remained the same [2015/08/13:12:00:00 AM].


Now, in SAS 9.4 when i use the same proc import to import the same text file to SAS dataset, the column with the value [2015/08/13:12:00:00 AM] comes in as a date format with the value changed to 13AUG15:00:00:00. We just moved from 9.2 to 9.4.

Here is the code that was working for me in 9.2.

proc import datafile="C:\Desktop\Sample.txt"








I tried to use the option usedate=no but SAS throws me an error.

Jade | Level 19

It looks like the change with 9.4 is to read the variable as DATE and format it with the default datetime format.  You can change the format to display to mdyampm using the format of the same name.


If you want character variable (not useful) you can PUT the data into a new variable using the MDYAMPM. format.


You could also modify the code generated by PROC IMPORT 


But why.  A datetime variable is much more useful that a character string of the same data.

Calcite | Level 5

Hi data_null_,

      The mdyampm format changes the value to  8/13/2015 12:00 AM from [2015/08/13:12:00:00 AM]. Now, the issue is i am pulling the year and month value from that column and with the new format there is no leading '0' in front of the single date value like '8'. i cannot use substring to pull those values, since the date value is either a single or double digit.

Is there a format to get the leading zero in the value such as 08/13/2015 12:00 AM instead of 8/13/2015 12:AM




Super User

If you are extracting values from a datetime variable then there are easy ways to do so:


Year = year(datepart(datetimevariablename));

Month = month(datepart(datetimevariablename));

Day = day(datepart(datetimevariablename));


Not to mention formats that will display the value as desired such as DTDATE, DTMONYY, DTWKDATX, DTYEAR, DTYYQC.

Jade | Level 19

As I mentioned and as @ballardw has demonstrated with and example, a DATETIME variable is much easier to work with than a character string.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 3 in conversation