Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 07-12-2012 04:31 AM
(1359 views)

How to get the median and other quantiles of data in the same row of several vectors using IML functions?

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

How to do it using SAS 9.2IML? Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You could adapt my code here which uses the SAS pctl function:

http://listserv.uga.edu/cgi-bin/wa?A2=ind0812A&L=sas-l&D=0&P=35674

But this is not a workable solution unless your matrices will always be small. As Dale said in the same thread:

http://listserv.uga.edu/cgi-bin/wa?A2=ind0812A&L=sas-l&D=0&P=37690

you will probably be better off building your own percentile function.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

proc iml;

start myQntl(q, x, p); /* definition 5 from UNIVARIATE doc */

y = colvec(x);

call sort(y,1);

n = nrow(y); /* assume nonmissing data */

q = j(ncol(p),1);

do i = 1 to ncol(p);

j = (n+1)*p*; /* position in ordered data */*

j1 = floor(j); j2 = ceil(j);/* indices into ordered data */

print j j1 j2;

if j1=j2 then /* return a datum */

q* = y[j1];*

else /* interpolate between data */

q* = (y[j2]+y[j1])/2;*

end;

finish;

/* test it */

x = ranuni(j(100,1));

p = {0.1 0.25 0.5 0.75 0.9};

call MyQntl(q, x, p);

print q;

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 16. Read more here about **why** you should contribute and **what is in it** for you!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.