BookmarkSubscribeRSS Feed
christinagting0
Quartz | Level 8

I have a character variable that I am trying to convert to SAS date format (mmddyy10.)

 

This is the code I am using:

data anzio_dados_fa;
	set anzio_dados_fa 

	(rename=(DISCHARGE_DOC=DISCHARGE_DOCNUM));
	DISCHARGE_DOC = input(DISCHARGE_DOCNUM, mmddyy10.);
	drop DISCHARGE_DOCNUM;

run;

However, when I do a proc contents and look at my variable, it seems to have only converted it to a number variable now. When I look at the "format" and "informat" columns after doing a PROC CONTENTS, these columns for my variable are just blank.

 

How do I convert my variable to a date format? What am I doing wrong in my above code?

 

Thanks in advance

 

 

 

 

 

 

 

 

1 REPLY 1
ballardw
Super User

It may help to show those actual Proc Contents results.

 

also if you want the result to LOOK like a date like 10/16/2016 instead of 27123 you need to assign a format:

 

format Discharge_doc mmddyy10.;

 

SAS does not automatically assign an informat just because you use a date informat in an input function unlike and INPUT statement with a format option.

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