turn on suggestions

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

Showing results for

Find a Community

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-12-2012 04:31 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-12-2012 06:34 AM

Look at the QNTL subroutine. The QNTL function operates on columns of a matrix, so if you have several vectors you can concatenate them together (use the || operator) and compute all the quantiles at once.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-26-2012 08:49 PM

How to do it using SAS 9.2IML? Thanks!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2012 03:01 AM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-27-2012 07:15 AM

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;