DATA Step, Macro, Functions and more

intck

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 117
Accepted Solution

intck

Hi Experts,

 

I have two tables, table aa have the acount number and acount open date, table bb have acount number and
launch_date. I am here trying to create a data set with acount numbers who have opened thiere accounts
7 days after the launch_date.  Am using weekday with intck fumction but not getting the desired output. please suggest.

 


data aa;
input act open_date;
informat open_date date9.;
format open_date date9.;
datalines;
0101 17Apr1990
0202 18May1990
0303 19Jun1991
0404 20Jul1992
;
run;


data bb;
input act launch_Date;
informat Launch_date date9.;
format Launch_date date9.;
datalines;
0101 20Apr1990
0202 21May1990
0303 19Jan2002
0404 20Jan2003
0505 21Jan2004
;
run;

 

Thanks & RegardS,

Sanjay


Accepted Solutions
Solution
‎10-16-2017 06:31 AM
Valued Guide
Posts: 593

Re: intck

I assume you mean WITHIN 7 days of opening the account as none of your sample data fits EXACTLY 7 days after opening. Of course "under the hood" dates are just numbers so a simple merge does the trick unless there's another requirement...

 

data want;
	merge aa bb;
	by act;
	if launch_date < open_date+8 then output;
run;

View solution in original post


All Replies
Solution
‎10-16-2017 06:31 AM
Valued Guide
Posts: 593

Re: intck

I assume you mean WITHIN 7 days of opening the account as none of your sample data fits EXACTLY 7 days after opening. Of course "under the hood" dates are just numbers so a simple merge does the trick unless there's another requirement...

 

data want;
	merge aa bb;
	by act;
	if launch_date < open_date+8 then output;
run;
Super User
Super User
Posts: 9,599

Re: intck

"Not getting the desired output" - this does not tell us anything about the issue?  From your problem:

proc sql;
  create table WANT as
  select  A.ACT,
          A.OPEN_DATE,
          B.LAUCH_DATE
  from    TABLEA A
  left join TABLEB B
  on      A.ACT=B.ACT
  where   A.OPEN_DATE=B.LAUNCH_DATE+7;
quit;
☑ This topic is solved.

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

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