BookmarkSubscribeRSS Feed
underarmnat
Fluorite | Level 6

Hi all,

 

I have just started on SAS and have converted a text file and done multiple manipulations with it including changing dates into a relavant format.

 

I have a question, I want to recode one date point (data point 555) from 21/05/2006 to the 15/05/2006 and every method I use ends up with 1/1/1960. I have converted everything to the ddmmyy10. format.

 

For example;

data sunscreen;

modify sunscreen;

if studyid=555 then melanomadate = 15/05/2006;

 

This ends up with 1/1/1960

 

So I then tried

For example;

data sunscreen;

modify sunscreen;

if studyid=555 then melanomadate = ('15/05/2006', ddmmyy10.);

run;

 

And got error,

 

Any thoughts/ideas?

5 REPLIES 5
underarmnat
Fluorite | Level 6
Thank you, works!
ChrisNZ
Tourmaline | Level 20

15/05/2006 performs a division. The result is about 0, which is 01/01/1960 as a sas date.

Patrick
Opal | Level 21

@underarmnat

Your 2nd attempt was actually pretty close. You just forgot to also use the SAS INPUT() function to tell SAS what it should be doing with the date string and the informat.

data test;
  melanomadate = input('15/05/2006', ddmmyy10.);
  format melomadate ddmmyy10.;
run;
underarmnat
Fluorite | Level 6
Thanks for your help Patrick

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
  • 5 replies
  • 712 views
  • 0 likes
  • 3 in conversation