DATA Step, Macro, Functions and more

If then else with two date variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

If then else with two date variables

Hi, the data have 2 date variables and I wanted to create third one called PPC_closing

data final3;
set final2;
if whichone='decemberppc' then PPC_closing = PPC_CLOSING_EFF_DATE1;
else PPC_closing = PPC_CLOSING_EFF_DATE;
run;

 

but the result still showing numbers and missing values.

 

How to make it original date?


Accepted Solutions
Solution
‎02-22-2016 03:52 PM
Super User
Posts: 19,833

Re: If then else with two date variables

Posted in reply to bohonghong

How does SAS store dates? 

 

Apply a format, 

 

format new_var date9.;

View solution in original post


All Replies
Super User
Posts: 19,833

Re: If then else with two date variables

Posted in reply to bohonghong

Post some sample data?

 

Is your IF condition not working? If so, check and make sure the case of the word matches exactly.

Occasional Contributor
Posts: 19

Re: If then else with two date variables

the If is working but the new variable showing 20441 but I need to original date
Solution
‎02-22-2016 03:52 PM
Super User
Posts: 19,833

Re: If then else with two date variables

Posted in reply to bohonghong

How does SAS store dates? 

 

Apply a format, 

 

format new_var date9.;
Super User
Posts: 7,832

Re: If then else with two date variables

Posted in reply to bohonghong

If you want PPC_closing to appear as a date, you need to assign it a proper date format (FORMAT statement).

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

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

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