Date: Sun, 3 Aug 2008 20:47:16 -0700
Reply-To: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject: Re: dropping one variable from a huge dataset without recreating
it
In-Reply-To: <200808040258.m73AlshJ015768@malibu.cc.uga.edu>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
Aside from speed (which I haven't tested) and ease of use, the ALTER
TABLE approach has another advantage: it will preserve the SORTEDBY
attribute, indexes, and constraints.
Try this:
=====
proc sort data=sashelp.class out=class (index=(name));
by name;
run;
proc sql;
alter table class
drop age;
quit;
proc contents data=class;
run;
=====
The listing will contain, among other things:
=====
Alphabetic List of Indexes and Attributes
# of
Unique
# Index Values
1 Name 19
Sort Information
Sortedby Name
Validated YES
Character Set ANSI
=====
A data step approah would require much more work if you wanted to
preserve these attributes.
--
Jack Hamilton
jfh@alumni.stanford.org
On Aug 3, 2008, at 7:58 pm, Chan Rajaram wrote:
> Thanks all!
>
> On the same note what would be fastest way to recreate a
> dataset(dropping
> the variable in question)? Its not for my use so the view is out of
> question so it needs to be a dataset.
>
> I can use this simple code to do what I need
> data xyz;
> set xyz(drop = vartobedropped);
> run;
>
> (or)
> Like Howard was saying is this any faster?
>
> proc sql;
> alter table xyz;
> drop vartobedropped;
> quit;
>
> (or)
>
> proc append base=abc data=xyz(drop=vartobedropped);
> run;
> Then I can delete xyz and rename abc to xyz.
>
> Which of the above three is faster? I know append usually works well
> for
> concatanating datasets(especially for temporary datasets from one of
> the
> SUGI papers I have read) as it reads just the base dataset compared
> to a
> set statement which has to read all the datasets
>
> Let me know if you guys have been in a situation like this (copying
> one
> dataset) and have used something that's been tried/tested and has been
> faster compared to others?