BookmarkSubscribeRSS Feed
ren2010
Obsidian | Level 7

Hi,

I have a dataset with a numeric variable  with informat and format of 9.This numeric field has date value as below:

date_var

20051020

I tried to read in the variable in a Data step and change the format  of date_var to mmddyy10. and  created the dataset,but when I opened  the dataset  the value of date_var is showing in bestw format.

ie in my output dataset I am seeing the value of date_var as 20051020 instead of 10/20/2005.

I have also noticed in the log that there was a message when I opened the output dataset ,ie : Error in Format,bestw used instead.

Any idea why this is happening?

Please help.

Thanks in advance.

2 REPLIES 2
art297
Opal | Level 21

It sounds like you read your dates as numbers.  Thus, you have to use the input and put functions to convert them to date values.  E.g.:

data have;

  input date_var;

  cards;

20051020

;

data want;

  set have;

  format date_var mmddyy10.;

  date_var=input(put(date_var,z8.),yymmdd8.);

run;

ren2010
Obsidian | Level 7

Thanks Art297.

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
  • 2 replies
  • 792 views
  • 0 likes
  • 2 in conversation