how to clear work library

sas

    Next

  • 1. PRX trivia
    Dear Past, Present & Future Regex Gurus, Consider the following data set: data fubar; input var1 $10.; datalines; deathstar ; run; Are the two WHERE statements below equivalent? data _fubar1; set fubar; where var1 like '%star'; /* WHERE statement #1 */ put var1= ; run; data _fubar2; set fubar; where prxmatch('/star$/',var1); /* WHERE statement #2 */ put var1= ; run; Think really hard b/c this is a trick question ... or maybe it isn't? Ken
  • 2. Read SAS dataset into external program
    Hi all, Is there a way to read a SAS dataset directly from an external program (say, in C)? Currently I am writing the file out to disk, reading it in, performing the calculations, writing the results back out to disk and then reading them in with SAS again. This all seems terribly inefficient. For the life of me I cannot find (on the web) a better way. Thanks in advance, Rick
  • 3. modifying a master data set with a transaction data set
    Hi, T is the transaction data set and M is the master data set. The column a has an index on it on the master data set. When submitting the last data set, I get an error message: ERROR: No matching observation was found in MASTER data set. a=1 newb=48 b=48 _ERROR_=1 _IORC_=1230015 _N_=2 NOTE: The SAS System stopped processing this step because of errors. I don't understand this why I get this error message, or how it could do the updating of the master data set with the transaction data set when the master data set has duplicates on the index column a. data T; input a b; datalines; 1 32 1 48 ; data M; input a b; datalines; 1 20 2 24 ; proc sql; create unique index a on work.m(a); quit; data m; set t(rename=(b=newb)); modify m key = a; b = newb; run; Rune

how to clear work library

Postby doyle » Sat, 22 Nov 2003 11:32:12 GMT

i am using sas for win 8.2. is there some line of code i can insert into 
my program that will clear the contents of the work library without 
having to quit the sas program? this would be the code equivalent to 
going into the explorer window, opening up the work folder and right 
clicking on each temp data set and choosing delete.

thank you
doyle


Re: how to clear work library

Postby michael » Sat, 22 Nov 2003 12:02:49 GMT

Hello Doyle and other SAS-L Friends,

How about:
proc datasets library=work kill ;
run ;
quit ;

This code will not delete a catalog or data set in use.

HTH.

- Michael "Mad Doggy" Davis




Michael L. Davis
Vice President
Bassett Consulting Services, Inc.
10 Pleasant Drive
North Haven  CT  06473-3712
E-Mail:   XXXX@XXXXX.COM 
Web:   http://www.**--****.com/ 
Telephone:    203-562-0640

Re: how to clear work library

Postby Arunk » Sat, 22 Nov 2003 14:33:57 GMT

Hi,
I suppose you want to delete all the data sets in the work(or any library)
 library. Try this one...

PROC DATASETS LIB=WORK MEMTYPE=DATA
    kill;
RUN;

But if you want to delete a particular datset, then try this one..

PROC DATASETS LIB=WORK MEMTYPE=DATA ;
    delete a; /* a is your data set*/
RUN;



Arun Kumar
ACDO2002
Tata Consultancy Services
C-56, Noida Phase-2, Noida
Phone: +91 120 2461001(Extn-1102)






doyle < XXXX@XXXXX.COM >
Sent by: "SAS(r) Discussion" < XXXX@XXXXX.COM >
11/21/2003 08:02 AM
Please respond to doyle


        To:      XXXX@XXXXX.COM 
        cc:
        Subject:        how to clear work library


i am using sas for win 8.2. is there some line of code i can insert into
my program that will clear the contents of the work library without
having to quit the sas program? this would be the code equivalent to
going into the explorer window, opening up the work folder and right
clicking on each temp data set and choosing delete.

thank you
doyle

Re: how to clear work library

Postby stigeide » Sat, 22 Nov 2003 18:56:22 GMT

proc delete data=work._all_;
run;
Stig Eide




Re: how to clear work library

Postby stigeide » Sat, 22 Nov 2003 19:05:48 GMT

If you like, you can put this into a KEY:
gsubmit "proc delete data=work._all_;run;";
That is, open the KEYS file (pressing F9 or submitting 'keys' in the command line.
Add the line under the KEY you want the command to be assigned to.
Stig Eide



Re: how to clear work library

Postby kerrir » Sun, 23 Nov 2003 00:50:12 GMT

what is MEMTYPE=DATA?  i just used PROC DATASETS the other day to delete one
dataset in my work library and didn't use MEMTYPE=DATA.  does one need to
specify that?

thanks,
~kerri

-----Original Message-----
From: Arun X Kumar
To:  XXXX@XXXXX.COM 
Sent: 11/21/03 12:33 AM
Subject: Re: how to clear work library

Hi,
I suppose you want to delete all the data sets in the work(or any
library)
 library. Try this one...

PROC DATASETS LIB=WORK MEMTYPE=DATA
    kill;
RUN;

But if you want to delete a particular datset, then try this one..

PROC DATASETS LIB=WORK MEMTYPE=DATA ;
    delete a; /* a is your data set*/
RUN;



Arun Kumar
ACDO2002
Tata Consultancy Services
C-56, Noida Phase-2, Noida
Phone: +91 120 2461001(Extn-1102)






doyle < XXXX@XXXXX.COM >
Sent by: "SAS(r) Discussion" < XXXX@XXXXX.COM >
11/21/2003 08:02 AM
Please respond to doyle


        To:      XXXX@XXXXX.COM 
        cc:
        Subject:        how to clear work library


i am using sas for win 8.2. is there some line of code i can insert into
my program that will clear the contents of the work library without
having to quit the sas program? this would be the code equivalent to
going into the explorer window, opening up the work folder and right
clicking on each temp data set and choosing delete.

thank you
doyle

Re: how to clear work library

Postby rjf2 » Sun, 23 Nov 2003 04:29:42 GMT

> From: Kerri Rivers [mailto: XXXX@XXXXX.COM ]

depends on your SOP: Standard Operating Procedure.
Many people name their format catalogs
with the same name as the data sets
that contain references to those formats.

the default for proc datasets is format=all
which means that
delete DataA;
will delete
DataA.dataset == DataA.sas7bdat
DataA.catalog == DataA.sas7bcat

PROC Datasets library  = Libref
              memtype  = data nolist
              memtype  = access all catalog data program view
                         kill force nolist nowarn
              ;          *end proc;
                         ;
              delete     DataName;
                         *exchange==swap two names;
              ;quit;
run;

This isn't likely to be a problem with
PROC Datasets library  = work;
              delete     DataA;

Ron Fehd  the macro maven  CDC Atlanta GA USA  XXXX@XXXXX.COM 

remember perspective: the error is not always where it seems to occur!
-- RJF2

Similar Threads:

1.Clearing work.GSEG window when working with GPLOT interactive

Dear SAS-L,

Does anyone know how to clear the work.GSEG window of plots from consecutive
plots (work.gseg.glpot[1..n]) when working with
SAS and running glpot interactively.

Thanks, any help is appreciated.

Jake

2.defaulte work library is not "work"

 After running following code, the defaulted work directory changed to
"user".
how can I change back it to "work" again?
Thanks.
Jeff



OPTIONS NONOTES NOSOURCE NOSOURCE2;

*option mprint mlogic symbolgen;

%let dir=M:\Users\JP\PM\PM_RF;

%let datasetdir=M:\Users\JP\PM\Participation Study;

%let testids=51,52,53;

%let client = ABB;

%let Period=RF;

%let SvcMths=2;

libname orig "&datasetdir.\datasets";

libname user "&dir.\userInputs";

*libname ret 'N:\PM\Participation Study\Results';

*libname extn odbc uid=&SYSUSERID dsn=mhcdatawh_dev schema=dbo
readbuff=5000;
*

proc* *datasets* lib=user kill;
*

run*;
*

proc* *datasets* lib=work kill;
*

run*;

/*Open definition file*/

options noxwait noxsync;

x '"C:\Program Files\Microsoft Office\Office12\excel.exe"';
*

data* _null_;

x=sleep(*5*);
*

run*;

*;

/* open Excel workbook */

/*"N:\PM\PM_RF\CSVs\definitionT.csv" */

*;

filename ddecmd dde 'excel|system';
*

data* _null_;

file ddecmd;

put "[FILE-OPEN(""&dir.\CSVs\definition.xls"")]";
*

run*;

*;

/* specify desired Excel worksheet cell range */

*;

filename xlin DDE "excel|&dir.\CSVs\[definition.xls]definition!r2c1:r500c3";
*

run*;

*;

/* read Excel files using DDE into SAS data set*/

*;
*

data* user.rfs_labels_all;

infile xlin dlm='09'x notab missover dsd;

informat id *8.* type $20. label $200.;

input id type label;

format id *8.* type $8. label $200.;
*

run*;

*;

/* close Excel workbook and close Excel */
*

data* _null_;

file ddecmd;

put "[FILE-CLOSE(""&dir.\CSVs\definition.xls"")]";

put '[QUIT()]';
*

run*;

/*********************************************

*********************************************

*********************************************/

/*Open codesetmap excel file*/

x '"C:\Program Files\Microsoft Office\Office12\excel.exe"';
*

data* _null_;

x=sleep(*5*);
*

run*;

*;

/* open Excel workbook */

/*"N:\PM\PM_RF\CSVs\definitionT.csv" */

*;



filename ddecmd dde 'excel|system';
*

data* _null_;

file ddecmd;

put "[FILE-OPEN(""&dir.\CSVs\codemap.xls"")]";
*

run*;

*;

/* specify desired Excel worksheet cell range */

*;

filename xlin DDE "excel|&dir.\CSVs\[codemap.xls]codemap!r2c1:r3000c4";
*

run*;

*;

/* read Excel files using DDE into SAS data set*/

*;
*

data* user.codesetmaps_all;

infile xlin dlm='09'x notab missover dsd;

informat id *8.* codesetvalue $20. codeid *8.* codetypecd *8.*;

input id codesetvalue codeid codetypecd;

format id *8.* codesetvalue $20. codeid *8.* codetypecd *8.* ;
*

run*;

*;

/* close Excel workbook and close Excel */
*

data* _null_;

file ddecmd;

put "[FILE-CLOSE(""&dir.\CSVs\codemap.xls"")]";

put '[QUIT()]';
*

run*;

/*For program test and debug*/








*

data* user.rfs_labels (where=(id in (&testids.))); *(where=(id^=.));*;

set user.rfs_labels_all;
*

run*;
*

data* user.codesetmaps (where=(id in (&testids.)));* (where=(id^=.));*;

set user.codesetmaps_all;
*

run*;



/*

proc import out=user.ClaimHitsDriver

datafile = "N:\HI_Analytics\Projects\NCQA_DM_Test\NCQA
Codes\HEDISHitsDriver.txt"

dbms=tab replace; getnames=yes;

run;

proc sql;

create table work.HitsDriver as

select distinct CodeTypeCd, ColumnName1, ColumnName2, ColumnName3

from user.ClaimHitsDriver;

quit;

*/
*

%macro* createdsns(id);

data work.&client._var_&id;

length Elig_id $*30*;

length rf_&id *8*;

output;

run;
*

%mend*;
*

proc* *datasets* lib=work kill;
*

run*;

/* move relative files from warehouse sever to work;

data work.&client._claims;

set extn.&client._&SvcMths._MTH_&period._CLAIM;

run;

data work.&client._elig;

set extn.&client._&SvcMths._MTH_&period._elig;

run;

data work.&client._pharm;

set extn.&client._&SvcMths._MTH_&period._pharm;

run;

*/

* move relative files from warehouse sever to work;
*

data* work.&client._claims (rename=(elig_id=claim_elig_id));

set orig.&client._CLAIMS;
*

run*;
*

data* work.&client._elig;

set orig.&client._elig;
*

run*;
*

data* work.&client._pharm (rename=(elig_id=pharm_elig_id));

set orig.&client._pharm;
*

run*;

*Get eligible meidcal claim;
*

proc* *sql* noprint;

create table work.claims as

select distinct cl.*

from work.&client._claims cl, work.&client._elig e

where cl.claim_elig_id=e.elig_id;
*

quit*;



*Get eligible pharm claims;
*

proc* *sql* noprint;

create table work.pharm as

select distinct ph.*

from work.&client._pharm ph, work.&client._elig e

where ph.pharm_elig_id=e.elig_id;
*

quit*;

* all elig member;
*

data* work.elig;

set work.&client._elig;
*

run*;

*Get all involved reps;
*

proc* *sql* noprint;

create table work.&client._RF as

select distinct elig_id

from work.abb_elig

quit;
*

proc* *sort* data=work.&client._RF;

by elig_id;
*

run*;

/*

proc sql noprint;

create table work.&client._RFall as

select distinct elig_id label="Elig_id"

from

(

select distinct elig_id

from orig.&client._elig

) as a;

quit;

*/









/* create dummy datasets*/


*

data* _null_;

set user.rfs_labels;

call execute('%createdsns('||strip(id)||');');
*

run*;


*

proc* *sql* noprint;

select count(*) into: numRF

from user.rfs_labels;
*

quit*;

/*Make a label stirng*/



/* Set up column of result table;

proc sql

proc sql noprint;

alter table work.&client._RF

add rf1 int;

quit;

*/



* trasform codeset maps;
*

proc* *sort* data=user.codesetmaps out=work.codesetmaps;

by id codetypecd;
*

run*;
*

Data* work.codesetmaps_mac_loookup (drop=codesetvalue) ;

Length ValueString $ *2000* ;

Set work.codesetmaps ;

By ID CodeTypeCD ;

Retain ValueString ;

ValueString = CatX( ',' , ValueString ,cats("'",CodeSetValue,"'")); ;

If Last.CodeTypeCD Then Do ;

Output ;

Call Missing( ValueString ) ;

End ;
*

run*;



/* Get a specific target dataset

data work.target;

set work.codesetmaps_mac_loookup;

where id=1;

run;*/




*

%Macro* calculateRFs(codetypecd, id, valueString);

%if &CodeTypeCd = *2* %then %do;

proc sql noprint;

select lowcase(strip(type)) into:idtype

from user.rfs_labels

where id=&id;

quit;

%if &idtype=binary %then %do;

proc sql noprint;

create table work.temp&id as

select distinct claim_elig_id as elig_id,

*1* as RF_&id

from work.claims

where claim_icd1_code in(&valueString) or

claim_icd2_code in(&valueString) or

claim_icd3_code in(&valueString);

quit;

%end;

%else %do;

proc sql noprint;

create table work.temp&id as

select claim_elig_id as elig_id,count(*) as RF_&id

from work.claims

where claim_icd1_code in(&valueString) or

claim_icd2_code in(&valueString) or

claim_icd3_code in(&valueString)

group by claim_elig_id;

quit;

%end;

%end;

%else %if &codetypecd=*3* %then %do;

proc sql noprint;

select lowcase(strip(type)) into:idtype

from user.rfs_labels

where id=&id;

quit;

%if &idtype=binary %then %do;

proc sql noprint;

create table work.temp&id as

select distinct pharm_elig_id as elig_id,

*1* as RF_&id

from work.pharm p

where p.pharm_ndc_code in

(

select ndc_code from sqlref.ref_ndc_mast

where ndc_thera_class_code in (&valueString)

);

quit;

%end;

%end;

 proc append base=work.&client._var_&id data=work.temp&id;

run;

*

%mend*;




*

data* _null_;

set work.codesetmaps_mac_loookup;

/*call execute ('%calculateRFs('||codetypecd||','||id||',' ||
'%nrstr('||trim(valueString)|| '));');*/

call execute ('%nrstr(%calculateRFs('||codetypecd||','||id||', %nrstr('||
trim(valueString)|| ')));');

*

run*;



/* Marco for sorting*/
*

%Macro* sortalldsn();

%do i=*1* %to *415*;

%if %sysfunc(exist(&client._rf_&i)) %then %do;

proc sort data=&client._rf_&i;

by id;

run;

%end;

%end;

*

%mend*;



option mprint mlogic symbolgen;

%*sortalldsn*();



*proc* *print* data=sashelp.class;
*

run*;




*

proc* *sql* noprint;

select cats("&client._var_",id) into: allids SEPARATED BY ' '

from work.codesetmaps_mac_loookup;
*

run*;
*

data* &client._all_rfs;

merge &client._rf &allids;

by elig_id;
*

run*;
*

proc* *print* data=abb_rf;
*

run*;

3.I am getting ERROR : Unable to clear or re-assign the library

Hi all,

I am running my program in batch mode. I am calling user defined macro
twice in my code. I that macro i am assigning library ARDATA. Since i am
calling user defined macro twice in the same session i am this error for
library assignments.
First time when i am calling i have no problem. But when i call second
time i getting this error. Please any one can help me in this.

ERROR : Unable to clear or re-assign the library ARDATA because it is
still in use.

Cheers,
Suhas

4.The clear command does not work for graphs window

Hi there,
I need to clear all the figures in the graph window that I created. But the
clear command which ususally works well for the output window failed to do
so. Anyone has the idea of that?
Thanks!
gim

5.Clear Output, Clear Log, Find

6. library WORK may not be reassigned

7. Mainframe Interactive SAS expanded WORK library

8. mainframe work library space question



Return to sas

 

Who is online

Users browsing this forum: No registered users and 18 guest