Re: SAS Macro to delete a SAS dataset 131840well, this one reminds me another thread recently discussed:
http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0911c&L=sas-l&F=&S=&P=4034
On Wed, 2 Dec 2009 08:50:34 -0800, SAS Techies <sastechiesblog@GMAIL.COM>
wrote:
>Here?s a simple SAS Macro to delete a SAS dataset?It takes the name of
>the SAS dataset as the parameter?
>
>%macro deletedsn(dsname);
>
>%if %index(&dsname,'.') eq 0 %then %do; %let lib=work; %let
>dsn=&dsname; %end;
>%else %if %index(&dsname,'.') eq 0 %then %do; %let lib=%scan(&dsnam...
Re: SAS Macro to delete a SAS dataset 196997> From: SAS Techies
> Subject: SAS Macro to delete a SAS dataset
>
> Here's a simple SAS Macro to delete a SAS dataset...It takes the name
of
> the SAS dataset as the parameter...
>
> %macro deletedsn(dsname);
>
> %if %index(&dsname,'.') eq 0 %then %do; %let lib=work; %let
> dsn=&dsname; %end;
> %else %if %index(&dsname,'.') eq 0 %then %do; %let lib=%scan(&dsname,
> 1,'.'); %let dsn=%scan(&dsname,1,'.'); %end;
>
> proc datasets lib=&lib nolist;
> delete &dsn;
> qui...
Re: SAS Macro to delete a SAS dataset #2 131884Proc delete cannot delete views (I just tried).
Of the macros suggested, I prefer the SQL version. The original
version does not work if the USER option is set to something other
than WORK.
Regards,
Søren
On Thu, 3 Dec 2009 08:41:55 -0600, Data _null_; <iebupdte@GMAIL.COM> wrote:
>I too like(d) PROC DELETE.
>
>When I used it I was forced to remove it and use PROC DATASETS because
>PROC DELETE is not documented.
>
>Also, but I have not tested it. How does it work with indexed data
>sets, audit trails, generation data groups, views, etc.?
...
Re: SAS Macro to delete a SAS dataset #2 313487I too like(d) PROC DELETE.
When I used it I was forced to remove it and use PROC DATASETS because
PROC DELETE is not documented.
Also, but I have not tested it. How does it work with indexed data
sets, audit trails, generation data groups, views, etc.?
I don't worry much about deleting, "all" of my programs run in batch
and are obsolete as soon as they are written.
On 12/3/09, Fehd, Ronald J. (CDC/CCHIS/NCPHI) <rjf2@cdc.gov> wrote:
> > From: SAS Techies
> > Subject: SAS Macro to delete a SAS dataset
> >
> > Here's a simple SAS...
SAS Macro to delete a SAS dataset
Here=92s a simple SAS Macro to delete a SAS dataset=85It takes the name of
the SAS dataset as the parameter=85
%macro deletedsn(dsname);
%if %index(&dsname,'.') eq 0 %then %do; %let lib=3Dwork; %let
dsn=3D&dsname; %end;
%else %if %index(&dsname,'.') eq 0 %then %do; %let lib=3D%scan(&dsname,
1,'.'); %let dsn=3D%scan(&dsname,1,'.'); %end;
proc datasets lib=3D&lib nolist;
delete &dsn;
quit;
%mend deletedsn;
%deletedsn(new);
%deletedsn(somelib.new);
Read more @ http://sastechies.blogspot.com/2009/12/sas-macro...
Re: Deleting SAS Data from a SAS DATASETOne thing you might do is to add an index on the snap_dt to the dataset; =
if that's there then you should be able to delete the records in place:
proc sql;
delete from prod.master_date;
where snap_dt =3D "&end_dt"d;
quit;
run;
In both the ways you are trying now you are creating new data sets =
rather than deleting records from the current data set; it would seem to =
me that a SQL delete statement would be faster than creating new =
datasets even if there isn't an index on the date.=20
-Mary
----- Original Message -----=20
From: SUBSCRIBE SAS-L Chandra Gadd...
sas macro call sas macro call sas macroHi, here is my test data set:
DATA one ;
INFILE cards ;
INPUT a b1 b2 b3 b4;
subjid+1 ;
CARDS ;
1 3 4 7 7
1 6 5 8 8
1 3 4 7 9
1 3 3 6 8
2 1 2 5 10
2 2 3 6 10
2 2 4 5 9
2 2 3 6 11
;
RUN ;
then I tried this code:
%macro pnt(data);
proc print data=&data.; run;
%mend pnt;
%macro loopSubset(data, subbasedon, funcmacro);
proc sort data=&data. nodupkey out=sublist(keep=&subbasedon.);
by &subbasedon.;
run;
PROC Sql;
select count(*) as cnt into : totlist
from sublist
quit;
run;
***** loop all subsets *****;
%do n=1 %to &totlist.;
d...
Re: Deleting SAS Data from a SAS DATASET #7A view helps on deletes, but I wonder how it affects performance of =
querying the data- wouldn't storing the data in 24 different locations =
cause a significant slowdown in perfomance upon querying the data versus =
having it all in one table that is indexed? If this data is queryied a =
lot but only deleted once a month, the time in querying (which probably =
is in peak time) could be much more important than the time in deleting =
(which could be run when the computer is not busy, such as nights or =
weekends). =20
-Mary
----- Original Message -----=20
From: ./ ADD NAME=3DData _n...
Re: Deleting SAS Data from a SAS DATASET #11And what about the time of the database administrator who now needs to =
keep track of 24 indexes to each index in the previous table? I just =
can't see our DB2 administrators would have ever thought to organize the =
data this way, though we had many very large tables, like the user had, =
that were purged by month; it does seem like it would be a lot of =
"people work" to manage 24 tables plus one index instead of just one =
table, even if querying didn't suffer(and I do think that it could).=20
-Mary
----- Original Message -----=20
From: Chang Chung=20
To: SAS-L@L...
Re: Deleting SAS Data from a SAS DATASET #8On 8/15/08, Mary <mlhoward@avalon.net> wrote:
> A view helps on deletes, but I wonder how it affects performance of querying the data- wouldn't storing the data in 24 different locations cause a significant slowdown in perfomance upon querying the data versus having it all in one table that is indexed? If this data is queryied a lot but only deleted once a month, the time in querying (which probably is in peak time) could be much more important than the time in deleting (which could be run when the computer is not busy, such as nights or weekends).
It is not the VIEW that has an...
Re: Deleting SAS Data from a SAS DATASET #4Summary: PROC DATASETS; AGE statement. + VIEWs
This won't help you delete data from your very big data set, but you
may find this example interesting.
You say you append data monthly to a big data set then when big gets
too big you need to clean out the old. And that takes a very long
time.
However if you don't physically append but use a view to
append/combine you may find it easier to get rid of the unwanted old
data.
Consider this code. it pushes MonthlyUpdate onto the stack of 24 data
sets and the 24th data set is deleted. Then all the data sets get
renamed to produce a new g...
Re: Deleting SAS Data from a SAS DATASET #10On Fri, 15 Aug 2008 17:20:13 -0500, Mary <mlhoward@AVALON.NET> wrote:
>And what about the time of the database administrator who now needs to keep
track of 24 indexes to each index in the previous table? I just can't see
our DB2 administrators would have ever thought to organize the data this
way, though we had many very large tables, like the user had, that were
purged by month; it does seem like it would be a lot of "people work" to
manage 24 tables plus one index instead of just one table, even if querying
didn't suffer(and I do think that it could).
....
hi,
Th...
Re: Deleting SAS Data from a SAS DATASET #2Chandra - this isn't my expertise area - I'm sure others may have better
ideas but I'll make three comments.
If your datasets have a large number of variables, in your datastep
method a WHERE clause will be more efficient - the IF statement causes
each record to be fully read before it can be selected for deletion. A
WHERE clause would only read the single variable in the case of records
that meet the criteria for deletion.
Data prod.Master_date;
set prod.master_date;
where snap_dt ne "&end_dt"d;
run;
You probably would be better off changing your data model t...
Re: Deleting SAS Data from a SAS DATASET #6I have been watching this thread today and I just now recall an example
that Paul Dorfman gave at a RUG several years ago and no, I don't recall
exactly where or when other than it was NESUG or SESUG in the past 5 years.
Anyway, Paul had a client who was storing something like the past 12 months
of transactions as variables andat the start of each month needed to stick
the just ended month on the end and drop the oldest month. Paul used Peek
to read the last 11 months of each obs as a single chunk of data, append
the current's month, and then used Poke to write the whole new obs as a
...