LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (December 2003, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 4 Dec 2003 14:22:49 +0000
Reply-To:     John Whittington <John.W@MEDISCIENCE.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         John Whittington <John.W@MEDISCIENCE.CO.UK>
Subject:      Re: Newbie Question How to Delete Variable from SAS Dataset
Comments: To: toby989 <toby989@HOTPOP.COM>
In-Reply-To:  <>
Content-Type: text/plain; charset="us-ascii"; format=flowed

At 05:27 04/12/03 +0100, toby989 wrote:

>Your suggestions create a new dataset (b) and copy only selected ones into >the new dataset from the old one (a). I would not want to do this, because >then I would have to delete a and rename b to a. I really only want to >delete one variable from a. If thats the only possibility SAS offers to do >it, then I think it doesn't allow for good programming practice, since >memory is still used up by the old dataset ...

Toby, if you don't want to retain the original dataset (a), then you can over-write it with the new one:

data a (drop = z) ; set a ; run ;

>.... and processor time/overhead is required by the whole copying process.

True, but if there were provision for simply deleting a variable/'column' 'in situ', without re-writing ('copying') the original, then it would have an inflated size, again using up memory/storage space unnecessarily.

It's also worth considering whether, if it's not a 'permanent' requirement (in which case it makes sense to re-write the smaller dataset), whether you actually need to delete the variable - since you always have the option to drop any un-needed variables in any DATA or PROC step; if you do that with a dataset option on the incoming dataset, the unwanted variables won't even be read into the step, for example:

data c ; set a (drop = z) ; ..... OR

proc whatever data = a (drop = z) ; ......

An alternative approach would be to create a dataset view, for example:

data b (drop = z) / view=b ; set (a) ;

In this case, dataset (b) does not actually exist, and therefore does not occupy any memory/storage space; it is a 'virtual dataset' which will be created from (a), by omission of variable z, each time 'dataset b' is referenced.

Kind Regards


---------------------------------------------------------------- Dr John Whittington, Voice: +44 (0) 1296 730225 Mediscience Services Fax: +44 (0) 1296 738893 Twyford Manor, Twyford, E-mail: Buckingham MK18 4EL, UK ----------------------------------------------------------------

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