BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aerbe
Calcite | Level 5

Is there a way to change the letters in a variable name from uppercase to lowercase?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
BobD
Fluorite | Level 6

Use the RENAME statement in PROC DATASETS (avoiding recreating the data set):

data have;
  myvar = 0;
run;

data _null_;
  set have;
  put _all_;
run;

proc datasets lib=work nolist;
  modify have;
     rename myvar=MYVAR;
run;
quit;

data _null_;
  set have;
  put _all_;
run;

View solution in original post

6 REPLIES 6
art297
Opal | Level 21

Never did it!  However, rename in a datastep should work (e.g., UNTESTED:)

data sashelp.class;

  set sashelp.class(rename=(name=NAME));

run;

I can't test it at the moment, but I would think that the lowcase, upcase and propcase functions could be used as well.  e.g.,

data sashelp.class;

  set sashelp.class(rename=(name=upcase(NAME)));

run;

Howles
Quartz | Level 8

I think you need %SYSFUNC, as in

data have ;

myvar = 0 ;

run ;

data want ;

set have(rename=(myvar=%sysfunc(upcase(myvar))));

put _all_ ;

run;

RICARDOIS
Calcite | Level 5
%let per = %sysfunc(lowcase(&period));
%put &per;
feb2017

With this I can now read/email sas datasets. filename_@per.sas7bdat files in UNIX/LINUX !!! Yey!!!
BobD
Fluorite | Level 6

Use the RENAME statement in PROC DATASETS (avoiding recreating the data set):

data have;
  myvar = 0;
run;

data _null_;
  set have;
  put _all_;
run;

proc datasets lib=work nolist;
  modify have;
     rename myvar=MYVAR;
run;
quit;

data _null_;
  set have;
  put _all_;
run;

aerbe
Calcite | Level 5

Thanks Bob, this worked well!

Linlin
Lapis Lazuli | Level 10

How about:

data have;

input (AA  BB  cc) ($);

cards;

qw er ty

cd rt ty

;

proc print;run;

proc sql noprint;

select catx('=',name,lowcase(name)) into : names separated by ' '

  from dictionary.columns

    where libname='WORK' and memname='HAVE';

quit;

proc datasets lib=work nolist;

modify have;

rename &names;

run;

quit;

proc print;run;

Linlin

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 37703 views
  • 1 like
  • 6 in conversation