BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bijayadhikar
Quartz | Level 8

HI,

I am looking to create a new column with max date. That mean my new column 'max_date should have  27jul2012 for all the caseid? 

 

data have;
input caseid $ myDate date9.;
format myDate date9.;
datalines;
34 27jul2010
35 27jul2011
37 27jul2012

;
run;

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
SK_11
Obsidian | Level 7

 

Output:

caseid myDate maxDate
34 27-Jul-10 27-Jul-12
35 27-Jul-11 27-Jul-12
37 27-Jul-12 27-Jul-12

View solution in original post

4 REPLIES 4
SK_11
Obsidian | Level 7

Try this:

Proc sql;
Create table want as 
Select *, max(myDate) as maxDate format date9.
from have
;Quit;

Output:

caseid myDate maxDate
34 27-Jul-10 27-Jul-10
35 27-Jul-11 27-Jul-11
37 27-Jul-12 27-Jul-12
PaigeMiller
Diamond | Level 26
Proc sql;
Create table want as select *, max(mydate) as max_date format=date. from have;
Quit;
--
Paige Miller
SK_11
Obsidian | Level 7

 

Output:

caseid myDate maxDate
34 27-Jul-10 27-Jul-12
35 27-Jul-11 27-Jul-12
37 27-Jul-12 27-Jul-12
bijayadhikar
Quartz | Level 8
Sorry for inconvenience.
I found a solution. just ignore.
Bijay

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