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

Hi,

I have a character variable for date, which shows like '23-JUN-12'. I was trying to convert this char variable into numeric, but could not do that. It seems that SAS does not have format for the date format like '23-JUN-12'. Could you let me know how to do? Thanks so much!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Remove the dashes and use date9? You can use compress function to remove the -

View solution in original post

4 REPLIES 4
Reeza
Super User

Remove the dashes and use date9? You can use compress function to remove the -

michellel
Calcite | Level 5

it works! thanks so much!

Tom
Super User Tom
Super User

DATE11 works.

data xx;

  input x date11.;

  format x date9.;

  put x=;

cards;

23-jun-12

23jun12

23jun2012

;;;;

Ksharp
Super User

ANYDTDTE11 works.

Code: Program



data xx;
  input x anydtdte11.;
  format x date9.;
  put x=;
cards;
23-jun-12
23jun12
23jun2012
;;;;


Log: Program

Notes (2)

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

53 

54 

55 

56 data xx;

57 input x anydtdte11.;

58 format x date9.;

59 put x=;

60 cards;

x=23JUN2012

x=23JUN2012

x=23JUN2012

NOTE: DATA statement used (Total process time):

  real time 0.84 seconds

64 ;;;;

NOTE: The data set WORK.XX has 3 observations and 1 variables.

  cpu time 0.58 seconds

  

65 

66 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

76 

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
  • 4 replies
  • 913 views
  • 0 likes
  • 4 in conversation