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

yymmdd10.

lho
Calcite | Level 5 lho
Calcite | Level 5

Here is how I solved the problem with some explanations. (Basically the same as it's been answered in all the previous threads).

Problem:

Original var: has data that looks something like... 20070131

I want var to look like this: 01/31/2007

data new;

     set old;

new_var = input (put(old_var,8.), yymmdd8.); <-- put(old_var,8.) changes the old_var's data type from numeric to character. Then, the input function changes old_var into a SAS date.

format new_var mmddyy10.; <-- after it has been changed into a SAS date, then you have the option to format it any way you want. The mmddyy10. gives me the appearance I want (01/31/2007). I believe if you would  like it to be 01-31-2007, instead of mmddyy10. you can use mmddyyd10.

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