DATA Step, Macro, Functions and more

date impute

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

date impute

I want impute the below date to DATE variable

 

30 – if day missing

 

June- if month missing

 

DATE

1963

1955-Apr

1987

1990-Aug


Accepted Solutions
Solution
‎01-19-2017 10:28 AM
Super User
Posts: 6,932

Re: date impute

Recommend using 28 for day when month = 'Feb' Smiley Wink

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Super User
Posts: 7,395

Re: date impute

Dunno what kind of date format your using there is you have YYYY-MON?  Basically split it to three parts, make your updates, then put it back together:

data want;
  set have;
  yr=scan(thedate,1,"-");
  mon=scan(thedate,2,"-");
  day=scan(thedate,3,"-");
  if mon="" then mon="Jun";
  if day="" then day="30";
  want_date=input(cats(day,mon,yr),date9.);
run;
Solution
‎01-19-2017 10:28 AM
Super User
Posts: 6,932

Re: date impute

Recommend using 28 for day when month = 'Feb' Smiley Wink

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 127 views
  • 1 like
  • 3 in conversation