BookmarkSubscribeRSS Feed
KellyW1117
Calcite | Level 5

Hello all,

Please help with the issue here. I have a list of IDs with their eligibility from and thru date.

 

For instance:

ID From Thru:

1  01/01/2012  01/01/2016

2  01/01/2015  12/31/2015

3  01/01/2014  07/01/2015

4  03/01/2012  09/01/2016

 

I would like my results to look like:

ID From Thru:

1  01/01/2015  12/31/2015

2  01/01/2015  12/31/2015

3  01/01/2015  07/01/2015

4  01/01/2015  12/31/2015

 

I used the if statement below and produce blank from and thru results that looks similar to:

ID From Thru:

1  .  .

2  01/01/2015  12/31/2015

3 .  07/01/2015

4  .  .

 

Can anyone help me with this issue? Thank you!!

 

if year(from) < &current_year. then from = &service_start_date_dateform.;
if year(thru) > &current_year. then thru = &service_end_date_dateform.;

4 REPLIES 4
ballardw
Super User

Please show the values of your macro variable &current_year, &service_start_date_dateform and &service_end_date_dateform. Also are your From and Thru variables SAS date values or Character values that look like dates?

KellyW1117
Calcite | Level 5

Hello,

The macro is attaced here:

%let service_start_date_dateform = '01JAN2015';
%let service_end_date_dateform = '31DEC2015';

%let current_year = 2015;

 

Both the from and thru are in the date format with length=8

 

I have tried where statement or "if, else if"; both wont work. 

LinusH
Tourmaline | Level 20

Since you are referring to an error, it would be nice to see the log.

First, you need the dates to be stored as SAS dates.

If you are using macro variable as constants, I think the easiest is to have them formatted as DATE9, so you can use them in the assignment as:

"&service_start_date_dateform."D

 

Data never sleeps
KellyW1117
Calcite | Level 5

Thank you very much! Adding "d" at the end of the macro works!! 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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