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 (February 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 10 Feb 2005 11:22:44 -0500
Reply-To:     "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:      Re: Creating a dataset without step boundaries in Base SAS

m n wrote: > Dear SAS-L, > > I developed a simple macro that finds a unique data > set name in the WORK directory (to avoid clashes for > temporary data sets), and I want the macro to create a > 0 obs 0 variable placeholder data set so that on > future invocations the macro won't return the same > "unique" name. > > In SCL, the open() function has an 'N' mode for > creating a new dataset, but it doesn't seem to work > for the Base SAS version of open() (at least for > v8.0). Is there any other way of creating a data set > with out a step boundary (i.e. without data _null_; > stop; run;)? I want to avoid the step boundary so > that the macro can be treated as a function, emitting > the unique name as in: > > %let TMP = %get_uniq_dsn();

I am unaware of a Base SAS function or call routine that creates a table. SCL functions COPY and RENAME are also not in Base.

There is a way though. Use the operating system to copy the underlying files of the table. This crude example demonstrates the idea. Not robust.

data null; stop; run;

%macro copyViaOs (src, dst);

* only works for librefs that are _not_ concatenated paths;

%let syslast = &src;

%let srclib = %scan (&syslast,1,.); %let srcmem = %scan (&syslast,2,.);

%let syslast = &dst; %let dstlib = %scan (&syslast,1,.); %let dstmem = %scan (&syslast,2,.);

%let srcpth = %sysfunc(pathname(&srclib)); %let dstpth = %sysfunc(pathname(&dstlib));

%let oscmd = copy &srcpth.\&srcmem..* &dstpth.\&dstmem..*;

%put &oscmd; %sysexec (&oscmd);

%mend;

data classes; set sashelp.class; run;

proc sql; drop table work.class; quit;

%put EXISTS? %sysfunc(exist(WORK.CLASS)); options noxwait xsync xmin; * xsync is important; %copyViaOs (classes, class); %put EXISTS? %sysfunc(exist(WORK.CLASS));

%copyViaOs (null, %myNewUniqueName);

-- Richard A. DeVenezia http://www.devenezia.com/


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