BookmarkSubscribeRSS Feed
jaymin_shah
Calcite | Level 5

I have used If first. and last. options in data step. 

But, couldn't find any similar options in proc sql.

Please provide me the solution for this issue.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

These options do not exist in PROC SQL.

 

They exist in DATA steps.

 

Thus, if you need to use these options, you would use a DATA step and not PROC SQL.

--
Paige Miller
PGStats
Opal | Level 21
  • Conceptually, SQL operates on unordered sets of records. Operations such as first, last, next, previous have no meaning in that context.
  • The DATA step on the other hand operates on a sequence of records. You will sometimes need to sort your data before running the DATA step. 


Use both! You will twice as efficient!

PG
LinusH
Tourmaline | Level 20
"Please provide me the solution for this issue"
Yeah, what exactly is your issue?
Syntax itself us never an "issue".
Data never sleeps
Peter_C
Rhodochrosite | Level 12
Linus
I think the issue is establishing the first and last rows within groups. The limitation of sql was not justified.
The result (finding first. And last. Rows) is native to data steps. My issue is the unexplained constraint (using sql).
But it really is no issue at all.
Patrick
Opal | Level 21

I believe @PGStats comment nailed it.

Having said that: Some database SQL extensions provide "first" and "last" as analytics functions http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions056.htm ... but then: They don't have the SAS data step and implementing the same with PLSQL can be painful.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 5 replies
  • 695 views
  • 1 like
  • 6 in conversation