Help using Base SAS procedures

how to use proc sql max(date) please

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

how to use proc sql max(date) please

Hello,

 

I am a sas beginner. I try to sorted by application_number and appstatusdate:

and get the following result: for example for one application_number:

1009226470    .................. 19May2016:15:45:07

1009226470    .................. 19May2016:15:45:07

1009226470    .................. 19May2016:15:49:15

1009226470    .................. 19May2016:15:49:15

1009226470    .................. 19May2016:15:49:15

1009226470    .................. 19May2016:15:49:15

 

I omited some varables in the middle. I am now trying to keep the lastest result. but I can not use If last. because it will only keep 1 obs. for the example above, I try to keep the last date 10May2016:15:49:15, but it has multiple obs. how can I code that? someone told me use date=max(date). I tried but full of errors. Can anyone help one this please? Thanks very much.


Accepted Solutions
Solution
‎01-17-2017 02:27 PM
Super User
Posts: 5,427

Re: how to use proc sql max(date) please

Posted in reply to septemberbulb
You could use the having max(appstatusdate) = appstatusdate constrict in SQL.
Data never sleeps

View solution in original post


All Replies
Trusted Advisor
Posts: 1,560

Re: how to use proc sql max(date) please

Posted in reply to septemberbulb

What code did you try to test ?

Contributor
Posts: 28

Re: how to use proc sql max(date) please

I currently use proc sql by application_number, appstatusdate. I don't know use wich statement to keep the lastest datetime.
Super User
Posts: 11,343

Re: how to use proc sql max(date) please

Posted in reply to septemberbulb

What is your desired result? Show the result.

 

And when discussing this with SAS users that is a datetime value you are showing. Which is very different than a date. In SAS terms one is measured in seconds (time or datetime) and the other days (date). So you can get very unexpected results when applying a rule for a "date" to "datetime" values.

Contributor
Posts: 28

Re: how to use proc sql max(date) please

Capture.PNG

I sorted by the appstatusdate in the datetime format and hope to keep the last datetime which in this example is  four obs. How can keep the last datetime even they have multiples? thx

Solution
‎01-17-2017 02:27 PM
Super User
Posts: 5,427

Re: how to use proc sql max(date) please

Posted in reply to septemberbulb
You could use the having max(appstatusdate) = appstatusdate constrict in SQL.
Data never sleeps
Contributor
Posts: 28

Re: how to use proc sql max(date) please

Thank you very much. I have a long way to learn.
☑ This topic is solved.

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

Discussion stats
  • 6 replies
  • 282 views
  • 0 likes
  • 4 in conversation