LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2001, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 1 Oct 2001 12:36:44 -0700
Reply-To:     Dale McLerran <dmclerra@MY-DEJA.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <dmclerra@MY-DEJA.COM>
Subject:      Re: SAS/IML manipulating subscripts
Comments: To: philippe.guiblin@ons.gov.uk
Content-Type: text/plain

Philippe,

Here is a little program which demonstrates one method of selecting a subset. There are other ways, and I do not claim that the method demonstrated is in any way optimal.

proc iml; /* generate a vector to sample from */ x = (1:5)`;

/* determine size of vector */ N = nrow(x);

/* nonzero values of vector VECUSE are rows to be selected */ vecuse = (1:n)`#(x^=3);

/* Sort VECUSE returns nonselected (0) values at front */ cvecuse = vecuse; vecuse[rank(vecuse),] = cvecuse;

/* determine start value of first nonzero element */ begin = sum(vecuse=0) + 1;

/* Get subset of X using nonzero subset of vecuse */ xsubset = x[vecuse[begin:n,],]; print xsubset; quit;

Alternatively, you could count the number of observations in your matrix or vector which should go into the subset, initialize the subset matrix or vector using the J function, and loop over the original matrix filling in the next row of the subset matrix if the row of the original matrix is not to be excluded.

Dale

>Date: Mon, 1 Oct 2001 17:04:07 +0100 >Reply-To: Philippe.Guiblin@ONS.GOV.UK > Philippe Guiblin <Philippe.Guiblin@ONS.GOV.UK> SAS/IML manipulating subscripts SAS-L@LISTSERV.UGA.EDU >Dear all, > >does anyone know how within SAS/IML I can delete observations. >For example within a data set "dat" containing the variable v1, v2, v3, I >would like to delete >the observations corresponding to the values of v3 equal to 3. > >Thanks for your help. > >Philippe > > > > >For the latest data on the economy and society >consult National Statistics at http://www.statistics.gov.uk > >********************************************************************** >Please Note: Incoming and outgoing email messages >are routinely monitored for compliance with our policy >on the use of electronic communications >********************************************************************** >Legal Disclaimer : Any views expressed by >the sender of this message are not necessarily >those of the Office for National Statistics >**********************************************************************

--------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

------------------------------------------------------------ --== Sent via Deja.com ==-- http://www.deja.com/


Back to: Top of message | Previous page | Main SAS-L page