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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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