BookmarkSubscribeRSS Feed
peka0027
Calcite | Level 5

-importing a file to SAS from excel
-contains a date in format like 17mar2000:00:00:00 imported as character
-want it to be formatted like 200003

tried

newdate=datepart(date1);
put newdate=yymmn7.;

3 REPLIES 3
Linlin
Lapis Lazuli | Level 10

data have;

input dt $ 20.;

cards;

17mar2000:00:00:00

;

data want(drop=dt);

set have;

date=put(input(scan(dt,1,':'),date9.),yymmn7.);

proc print;run;

peka0027
Calcite | Level 5

Sorry I should have been more specific.  I have a column of dates in this format (different dates) and want to reformat the entire column to the new format.

Tom
Super User Tom
Super User

Excel does not understand SAS's syntax of placing a colon between the date and the time.

But SAS does Smiley Happy

data xx;

  input date1 $20.;

  new_date=datepart(input(date1,datetime.));

  format new_date yymmn6.;

  new_char=put(datepart(input(date1,datetime.)),yymmn6.);

  put (date1 new_date new_char) (=);

cards;

17MAR2000:00:01:45

run;

date1=17MAR2000:00:01:45 new_date=200003 new_char=200003

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!

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