BookmarkSubscribeRSS Feed
Alkibiades
Obsidian | Level 7

My task in DI Studio is to find first and last observations in a group after a sort transformation (and user written code is a no go) has been applied.

 

So far I stumbled over the option to use two sequential sorts, the first one creating the sort order and the second one keeping the first observation with the nodupkey option, discarting all others. 

Also the rank transformation cann be used to create a rank order including the numeric rank variable. Keeping the rank 1 observation does the job as well. But it only functions if you sort numeric fields and does not help if you only sort alphanumeric values.

 

Is there a DI Studio in-house transformations/option in atransformation that lets me keep either first or last observations?

1 REPLY 1
LinusH
Tourmaline | Level 20

Not OOTB that I'm aware of.

But is this really a common task? I usually do the "twin Sort" transformation to achieve this, it's not that ugly.

I feel you when you want to avoid user written code, but if this is a common situation, writing a user written transformation is not that bad...

Data never sleeps

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1597 views
  • 1 like
  • 2 in conversation