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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

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

2 REPLIES 2
ChrisBrooks
Ammonite | Level 13

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;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

"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;

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!

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
  • 761 views
  • 0 likes
  • 3 in conversation