DATA Step, Macro, Functions and more

SAS EG

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

SAS EG

I have date column in which if blank comes i want to fill it with year end date how can i do it ?

Example:-

 

Date

22JUN2016

-

-

01JAN2016

22JAN2016

12FEB2016

-

 

 

then i want

 

Date

22JUN2016

31DEC2016

31DEC2016

01JAN2016

22JAN2016

12FEB2016

31DEC2016

 


Accepted Solutions
Solution
‎08-03-2016 03:48 AM
Super Contributor
Posts: 266

Re: SAS EG

Posted in reply to ashishj816

 

data temp;
informat date_val date9.;
input date_val;
if date_val = . then date_val ='31Dec2016'd;
datalines;
22Jul2016
.
21Aug2016
;

 

 

 

View solution in original post


All Replies
Super User
Posts: 7,868

Re: SAS EG

Posted in reply to ashishj816

I assume you want to take it from previous observations.

data want;
set have;
retain keepyear;
if date ne .
then keepyear = year(date);
else date = mdy(12,31,keepyear);
drop keepyear;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎08-03-2016 03:48 AM
Super Contributor
Posts: 266

Re: SAS EG

Posted in reply to ashishj816

 

data temp;
informat date_val date9.;
input date_val;
if date_val = . then date_val ='31Dec2016'd;
datalines;
22Jul2016
.
21Aug2016
;

 

 

 

☑ This topic is solved.

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

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