convert all table names into upcases

Reply
New Contributor
Posts: 3

convert all table names into upcases

Hi;

   I have a SAS library with more than 50 memnames, some memnames are in lower case, some upper and some mix, I want to convert all of them into upcase without loosing any information.

Tahir

Super User
Posts: 11,134

Re: convert all table names into upcases

Which OS are you using? SAS doesn't care much about case, so I'm assuming this has something that is OS dependent. In which case the methods are likely to be different.

Super Contributor
Posts: 644

Re: convert all table names into upcases

There is a simple solution involving proc transpose if all your variables are numeric (or all character).

This more general solution works for me in the University edition, however you may experience a problem where the name is already uppercase. (If the %put &myvars ; statement results in a string entirely composed of uppercase, you are out of luck)

data have ;

  CamelCase = 123 ;

run ;

proc print ;

run ;

proc sql noprint ;

  Select catx ("=",Name,upcase(Name))

  into  :myvars

  separated by " "

  from Dictionary.columns

  where libname = 'WORK'

  and memname = 'HAVE'

  and name <> upcase(name)

  ;

quit ;

%Put &myvars ;

Proc datasets library = work noprint ;

  modify have ;

  rename &myvars ;

quit ;

proc print ;

run ;

Richard

New Contributor
Posts: 3

Re: convert all table names into upcases

Hi;

1) Thanks for replying. I am using SAS 9.3(64bit) Windows

2) I want memname upcase, not the varibale names, library has almost 150 datasets, some datasets names are lower,some upper and some mix, my boss asked to convert all memname to uppcase without rewriting them.

Once again thanks for any help.

Super User
Super User
Posts: 7,721

Re: convert all table names into upcases

You could also call execute or call system the rename statement save on the writing the batch file.

data _null_;

     set sashelp.vtable (where=(libname="Your_libname"));

     call system('rename '||strip(memname)||' '||strip(memname));

run;

On a different note, you may want to be careful.  Case doesn't generally matter on Win, xyz.zyx = xyz.XYZ.  However if you have other software installed which is using this information you may find that it does matter.  Early versions of SVN for instance were prone to errors when two records of the same file, with different cases were present, as both want to extract to the same file on Win (but it would work fine on Unix).

Super User
Posts: 9,875

Re: convert all table names into upcases

A simple way is to make a BAT file and execute a bunch of OS command RENAME .

Assuming the library is c:\temp .

options noxwait ;
filename bat 'd:\rename.bat';
filename x pipe 'dir c:\temp\*.* /b ';
data _null_;
file bat;
infile x truncover;
input fname $50.;
if _n_ eq 1 then put 'cd c:\temp';
x=catx(' ','rename',fname,upcase(fname));
put x;
run;
x 'd:\rename.bat' ;

Xia Keshan

Valued Guide
Posts: 2,177

Re: convert all table names into upcases

Just upcase the memname only when you need to

 

I don't know in what context you want these memnames as uppercase.

if it is in a proc report or print just use the $UPCASE. format.

If it is for a query in proc sql just use

where upcase(memname) = "%upcase(&parameter)"

or something like this join

select U.*, S.nobs, S.modate, S.libname

From yourdata U join sashelp.vtable S

on upcase(S.memname) = upcase(U.memname)

New Contributor
Posts: 3

Re: convert all table names into upcases

Hi Thanks for help:

Actually  in SAS explorer window when i click on a certain library, some table names appear in uppere case ,some lower case, some mix because at the time when someone was writing those table names on the server he/she saved that way. Now I want to see all those table names in upper case, exclusively in explorer window not in any report or in any other query.

eg(In  SAS explorer windows)

content of mylib

mylib.WonderFull

mylib.yEsterday

mylib.all_Data_up

mylib.New_ARRIVAL

I want to see all these in upper case instead lower or mix . Make sure I do not want to rewrite a table name because library has more than 160 tables and data stays on server

Super User
Posts: 11,134

Re: convert all table names into upcases

I still think this is an Operating System issue and you haven't said which OS those files reside on. You may be able to use some of the above information to write a script for your OS to RENAME the files. Last time I checked practically every operating system has some form of RENAME that doesn't change the contents of the file.

Valued Guide
Posts: 2,177

Re: convert all table names into upcases

If your MYLIB is assigned through a SAS/ACCESS library engine, you have to work witb what is there as many of these external systems have table names wbich are case-sensitive ( including microsoft excel but not Oracle iirc). In that case-sensitive world there could be two different tables which would appear to have duplicate names when presented in uppercase.

If you create your own list you would be "in control" of how the names appear. I don't believe you can modify how the built-in listers present.

Good luck

Peter

Ask a Question
Discussion stats
  • 9 replies
  • 358 views
  • 2 likes
  • 6 in conversation