BookmarkSubscribeRSS Feed
shalmali
Calcite | Level 5

Hi All

I have a data set in excel which has some date information. I am trying to import it to sas. I have formated the date coloum in excel to date. As a result, in excel I can read the dates as mm/dd/yy. However when I import the data to SAS and read the dates, it is in different format. Also the date column is converted into character. For instance, the data in excel is as follows:

Firm     date

A     05/22/2008

B     2/19/2003

When I read the date in the SAS, it looks as follows:

Firm     date

A          39590

B          37671

The code I used to import the excel file into SAS is:

proc import out=work.a

datafile = "c:\users\destop\sas\b.xls"

dbms =xls replace;

getnames=yes;

run;

I would appreciate if someone help me modify this code so that I can read the date correctly.

Thank you.

1 REPLY 1
ballardw
Super User

Try applying a format such as mmddyy10 to the SAS data.

for example:

Proc print data=work.a;

var date;

format data mmddyy10.;

run;

The numeric values in the SAS data set are the number of days since 1 Jan 1960 and formats will display those numbers in a more human readable version.

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
  • 1 reply
  • 637 views
  • 0 likes
  • 2 in conversation