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 (April 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 13 Apr 2004 18:08:21 -0400
Reply-To:     Glenn Heagerty <gheagerty@EARTHLINK.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Glenn Heagerty <gheagerty@EARTHLINK.NET>
Subject:      Re: Rename a series of datasets
In-Reply-To:  <200404131350.1bduROdP3NZFl40@penguin>
Content-Type: text/plain; charset=us-ascii; format=flowed

Hi Dianne,

This example doesn't use dictionary tables, it does use the sashelp.vtable view though.

First, some background. I copied test tables to my work directory, then copied the vtable there, too. Next, I used a data step to select the entries of interest and write modify and change statements to a file. The final step is a PROC DATASETS that include the file written in step 2.

I hope you can use this to construct what you need. Just substitute your library, data file prefix, member type, and file destination. If any of your data set names are longer than your version limit then you will have to modify the code accordingly. Good luck,

Glenn

data work.prdsale; set sashelp.prdsale; run;

data work.prdsal2; set sashelp.prdsal2; run;

data work.prdsal3; set sashelp.prdsal3; run;

data work.vtable_copy; set sashelp.vtable; run;

data _null_; set work.vtable_copy(where=(upcase(libname) in ('WORK') and upcase(memname) =: 'PRD' and upcase(memtype) eq 'DATA')); file "$HOME/rename.sas"; length newname $32; newname = trim(substr(memname,1,3))||'OALL'||substr(memname, 4); put 'modify ' memname '; change ' memname '= ' newname ';'; run;

proc datasets lib=work mt=data; %include "$HOME/rename.sas"; quit; run;

Included file: modify PRDSAL2 ; change PRDSAL2 = PRDOALLSAL2 ; modify PRDSAL3 ; change PRDSAL3 = PRDOALLSAL3 ; modify PRDSALE ; change PRDSALE = PRDOALLSALE ;

Dianne Rhodes wrote: > Hi > > What is the easiest way to rename a series of datasets? I don't have write > access to them, so I am supposed to write a program that someone else can > execute to do the rename. I find lots of ideas for renaming variables, but > haven't flushed up anything on renaming the datasets. For example, I want > to rename a dataset MVNSU to MVNOALLSU, MVNCU to MVNOALLCU to feed into a > process that uses the dictionary tables and looks for MVN &SFX. * where &SFX > = OALL. This came about because it was decided after the fact to include > additional tables in the process. > > Dianne Louise Rhodes > Sr. Systems Analyst > Westat >


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