BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tellmeaboutityo
Obsidian | Level 7

Hi, I have a series of character variables that are actually dates.  I would like to get them into date format, but don't know how.  😞

 

They're currently in the format 10/2/2000.  Keeping that format is fine.  Knowing how to do it in a data step would be most convenient, but proc is fine too.  Thanks for any help! 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

As I haven't any test data in the form of a datastep, I am just guessing here:

data want (drop=i);
  set have;
  array cd{3} char_date1 char_date2 char_date3;
  array nd{3} num_date1 num_date2 num_date3;
  do i=1 to 3;
    nd{i}=input(cd{i},ddmmyy10.);
  end;
  format num_date: date9.;
run;

I assumed all your character dates were char_date1, 2 etc.  and you wanted num_date1, 2 etc.

in future please post test data in the form of a datastep so we have something to run rather than guessing.

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

As I haven't any test data in the form of a datastep, I am just guessing here:

data want (drop=i);
  set have;
  array cd{3} char_date1 char_date2 char_date3;
  array nd{3} num_date1 num_date2 num_date3;
  do i=1 to 3;
    nd{i}=input(cd{i},ddmmyy10.);
  end;
  format num_date: date9.;
run;

I assumed all your character dates were char_date1, 2 etc.  and you wanted num_date1, 2 etc.

in future please post test data in the form of a datastep so we have something to run rather than guessing.

tellmeaboutityo
Obsidian | Level 7
You nailed it! Thanks a bunch!

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
  • 854 views
  • 1 like
  • 2 in conversation