BookmarkSubscribeRSS Feed
Ashwini
Calcite | Level 5

I have a datset like

Stname  DOB
A            01mar2005 01:02:04
B            13dec 2001 05:04:06

I want to create below mention dataset from abov dataset  like

Stname  DOB
A            01\03\2005 01:02:04
B            13\12\ 2001 05:04:06

Kindly help me.

Thanks and Regards,
Ashwini

2 REPLIES 2
Haikuo
Onyx | Level 15

First of all, I am not awared of the existance of such a format, but at the same time, I am very ill-informed. Therefore I had to hard-code the following solution:

data want (drop=dob1);

input Stname $  DOB &$25.;

dob1=input(dob,datetime20.);

dob_final=catx(' ',put(datepart(dob1),mmddyy10.),put(timepart(dob1),time.));

cards;

A            01mar2005 01:02:04

B            13dec 2001 05:04:06

;

proc print;run;

Regards,

Haikuo

Ksharp
Super User
proc format;
picture fmt
 low-high='%0d\%0m\%Y %0H:%0M:%0S'(datatype=datetime);
run;
data want ;
input Stname $  DOB & datetime20.;
format dob datetime20.;
dob_final=dob;
format dob_final fmt.;
cards;
A            01mar2005 01:02:04
B            13dec 2001 05:04:06
;
run;

Ksharp

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1122 views
  • 0 likes
  • 3 in conversation