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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1403 views
  • 1 like
  • 2 in conversation