BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5
Hi i want to read these observations in the same variable dt as they are in ddmmyy10. and date11. and if date is like 0970 and 0001 it should be in to 1900

data l3;
input dt ;
cards;
01/03/0970
01/01/0001
01/01/2003
12-sep-2011

run;


output:
01/03/1900
01/01/1901
01/01/2003
12/09/2011
3 REPLIES 3
DBailey
Lapis Lazuli | Level 10
try

option datestyle=dmy;

data l3;
input dt anydtdte21.;
cards;
01/01/2003
12-sep-2011
run;
sss
Fluorite | Level 6 sss
Fluorite | Level 6
HI try this one;


data la;
input dt anydtdte21.;
format dt ddmmyy10.;
cards;
01/01/2003
12-sep-2011
run;
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello R_Win,

Is this what you need?
[pre]
data i;
input d $20.;
if SUBSTR(d,7) = "0970" then dt=INPUT(SUBSTR(d,1,6)||'1900',anydtdte21.);
else if SUBSTR(d,7) = "0001" then dt=INPUT(SUBSTR(d,1,6)||'1901',anydtdte21.);
else dt=INPUT(d,anydtdte21.);
format dt ddmmyy10.;
datalines;
01/03/0970
01/01/0001
01/01/2003
12-sep-2011
run;
[/pre]
Sincerely,
SPR

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1150 views
  • 0 likes
  • 4 in conversation