BookmarkSubscribeRSS Feed
light
Obsidian | Level 7

For the given data set with uneven number of observations, either character or numeric, how can I find and display the middle observation?

 

Thank you greatly 🙂

4 REPLIES 4
Reeza
Super User

Sample data and expected output. In the post rather than an attachment or image. 

light
Obsidian | Level 7

I am a bit confused...  I know how to find the middle number in a numerical data set, however if I decide to use character variables, I am getting missing values in output.

Thank you.

PGStats
Opal | Level 21

Use nobs= to get the number of obs. Get the mid obs with point= option :

 

data test;
do txt = "abc","def","ghi","jkl","mno";
    output;
    end;
run;

data mid;
if 0 then set test nobs=n;
n = ceil(n/2);
set test point=n;
output;
stop;
run;
PG
light
Obsidian | Level 7
Thank you. That works.

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 choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2636 views
  • 1 like
  • 3 in conversation