BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Adnan_Razaq
Calcite | Level 5

Hi,

 

I have the following dataset

data have;

input account_id reporting_date payment_day;
informat reporting_date  date9.;
format reporting_date  date9.;
cards;
1000 31JAN2017 10
1000 28FEB2017 10
1000 31MAR2017 10
1000 30APR2017 10
1000 31MAY2017 10
2000 31JAN2017 15
2000 28FEB2017 15
2000 31MAR2017 15
2000 30APR2017 15
;
run;

what I need is to use payment day and reporting month to get payment due date for each particular reporting month. For example for the first record the desired output will be 10JAN2017 and second record 10FEB2017

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

Split the date up with the month() and year() functions and then rebuild it with the mdy() function

 

data have;

input account_id reporting_date payment_day;
informat reporting_date  date9.;
format reporting_date  date9.;
cards;
1000 31JAN2017 10
1000 28FEB2017 10
1000 31MAR2017 10
1000 30APR2017 10
1000 31MAY2017 10
2000 31JAN2017 15
2000 28FEB2017 15
2000 31MAR2017 15
2000 30APR2017 15
;
run;

data want(drop= rmon ryear);
	format due_date date9.;
	set have;
	rmon=month(reporting_date);
	ryear=year(reporting_date);
	due_date=mdy(rmon,payment_day,ryear);
run;

View solution in original post

2 REPLIES 2
ChrisBrooks
Ammonite | Level 13

Split the date up with the month() and year() functions and then rebuild it with the mdy() function

 

data have;

input account_id reporting_date payment_day;
informat reporting_date  date9.;
format reporting_date  date9.;
cards;
1000 31JAN2017 10
1000 28FEB2017 10
1000 31MAR2017 10
1000 30APR2017 10
1000 31MAY2017 10
2000 31JAN2017 15
2000 28FEB2017 15
2000 31MAR2017 15
2000 30APR2017 15
;
run;

data want(drop= rmon ryear);
	format due_date date9.;
	set have;
	rmon=month(reporting_date);
	ryear=year(reporting_date);
	due_date=mdy(rmon,payment_day,ryear);
run;
JosvanderVelden
SAS Super FREQ

You could use something like the following:

 

      payment_due_date = mdy(month(reporting_date), payment_day, year(reporting_date));

 

Best regards, Jos

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 780 views
  • 1 like
  • 3 in conversation