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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20
You could use the having max(appstatusdate) = appstatusdate constrict in SQL.
Data never sleeps

View solution in original post

6 REPLIES 6
Shmuel
Garnet | Level 18

What code did you try to test ?

septemberbulb
Obsidian | Level 7
I currently use proc sql by application_number, appstatusdate. I don't know use wich statement to keep the lastest datetime.
ballardw
Super User

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.

septemberbulb
Obsidian | Level 7

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

LinusH
Tourmaline | Level 20
You could use the having max(appstatusdate) = appstatusdate constrict in SQL.
Data never sleeps
septemberbulb
Obsidian | Level 7
Thank you very much. I have a long way to learn.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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