BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Neil_Merchant
SAS Employee

Why not just age the dataset? Try:-

 

options symbolgen mprint mlogic;

libname scott '/ma/scott/';

 

%let work = %sysfunc(getoption(work));

 

/*ADD THE _NEW POSTFIX SO THAT THE DATASET CREATES A NEW DATASET THAT DOESN'T EXIST*/

 

data test_new;

   do id = 1 to 100000000;

      format blah $256.;

      do blah = 'blah blah blah';

         output;

      end;

   end;

run;

 

/*USE PROC DATASETS TO RENAME TEST_NEW TO TEST AND ALSO REMOVE THE OLD VERSION OF TEST*/

 

proc datasets lib=work

             nolist;

   age test_new test;

quit;

econ
Quartz | Level 8

Just tested it. That works as a workaround also. Still kind of clunky to have to do the extra step. Hoping SAS will release a patch.

 

Thanks for sharing.

Neil_Merchant
SAS Employee

Could make it a macro...

 

%macro overwrite(dset);

 

   /*IF THE DATASET NAME CONTAINS A . THEN EXTRACT THE LIBNAME AND DATASET NAME*/

   %if %index(&dset,%str(.))>0 %then

      %do;

         %let lref=%upcase(%scan(&dset,1,%str(.)));

         %let dsname=%upcase(%scan(&dset,2,%str(.)));

      %end;

   %else

      /*ELSE ASSUME LIBNAME IS WORK*/

      %do;

         %let lref=WORK;

         %let dsname=%upcase(&dset);

      %end;

 

   /*CONFIRM DATASET_NEW EXISTS BEFORE AGING*/

   %if %sysfunc(exist(&dset._new)) %then

      %do;

         /*RENAME DATASET_NEW TO DATASET AND REMOVE THE OLD DATASET*/

         proc datasets lib=&lref.

                       nolist;

            age &dsname._new &dsname.;

         quit;

      %end;

   /*ELSE THROW ERROR TO STATE AGING NOT DONE*/

   %else

      %do;

         %put ERROR: Dataset &dset._new does not exist;

      %end;

%mend;

 

data x;

   x=1;

run;

 

data x_new;

   x=2;

run;

 

%overwrite(x);

 

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 17 replies
  • 6976 views
  • 4 likes
  • 6 in conversation