BookmarkSubscribeRSS Feed
ywon111
Quartz | Level 8

Trying to create the table below, i.e. adding another condition in the codes where if there is same Event_date then only Count_done as 1.

 

PROC SQL;
Create Table want1 as select
want.*, source.result_date,
case
when standard_days ge result_date and Event_date le result_date then '1'
else '0'

end
as Count_done
from want left join source on want.ID = source.ID;
Quit;

 

Current code produces this:

IDEvent_dateCount_done
12345617/07/20181
12345617/07/20181
23456712/07/20181

 

This is what I want:

IDEvent_dateCount_done
12345617/07/20181
12345617/07/20180
23456712/07/20181

 

Thanks in advance 

2 REPLIES 2
Tom
Super User Tom
Super User

Why would you want to do that in SQL?

data want;
  set have;
  by id event_date;
  count_done = first.event_date;
run;
ChrisNZ
Tourmaline | Level 20

You are not showing all the fields you process.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 471 views
  • 1 like
  • 3 in conversation