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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1065 views
  • 0 likes
  • 3 in conversation