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

Hi all,

My SAS dataset named france has a variable Base_Date(Lenth:12, Format:$12, Informat:$12. Tpye: character). The obs. displayed like "2-Feb-06".

The attributes of Base_Date in other datasets are Lenth: 8 Format: DATE9.  Informat:DATE9.  Tpye: numeric and I want to convert the character date to numeric date just like the above.

My commands are as follows:

data france;

set france;

Base_Date=input(Base_Date,date9.);

run;

*failure, obs. like "2-Feb-06" becomes "16834";

*Lenth: 12 Format: $12. Informat: $12. Tpye: character remain the same;

I also tried some commands like below:

data france;

set france;

Base_Date=input(Base_Date,yymmdd8.);

run;

*failure, all obs. of this variable become missing values;


Could anyone give me some suggestions? Also I want to know why the attributes of Base_Date in a dataset are different from that in other datasets given that I import the data from the same type of file (CSV) to SAS using the same commands.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You need a format.

data france;

set france;

new_Base_Date=input(Base_Date,date9.);

format new_Base_Date date9. ;

run;

View solution in original post

1 REPLY 1
Ksharp
Super User

You need a format.

data france;

set france;

new_Base_Date=input(Base_Date,date9.);

format new_Base_Date date9. ;

run;

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