Help using Base SAS procedures

Reg:Date Issue

Reply
Regular Contributor
Posts: 229

Reg:Date Issue

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
Super Contributor
Posts: 578

Re: Reg:Date Issue

try

option datestyle=dmy;

data l3;
input dt anydtdte21.;
cards;
01/01/2003
12-sep-2011
run;
Contributor sss
Contributor
Posts: 65

Re: Reg:Date Issue

HI try this one;


data la;
input dt anydtdte21.;
format dt ddmmyy10.;
cards;
01/01/2003
12-sep-2011
run;
Super Contributor
Super Contributor
Posts: 365

Re: Reg:Date Issue

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
Ask a Question
Discussion stats
  • 3 replies
  • 176 views
  • 0 likes
  • 4 in conversation