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

Hi guys i am using sas eg 5.1 and i have one dataset name "data1" (50 obs), in "data1" have one variable name "empname" and all values for "empname" are in lower case. I want to change both variable name "empname" and all values in upcase. how can i do that?

please help!

thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

data have;

input empname $;

cards;

abc

bbv

cvb

;

data want;

  set have(rename=empname=EMPNAME);

  empname=upcase(empname);

proc print;run;

                               Obs    EMPNAME

                                   1       ABC

                                   2       BBV

                                   3       CVB

View solution in original post

11 REPLIES 11
Linlin
Lapis Lazuli | Level 10

data have;

input empname $;

cards;

abc

bbv

cvb

;

data want;

  set have(rename=empname=EMPNAME);

  empname=upcase(empname);

proc print;run;

                               Obs    EMPNAME

                                   1       ABC

                                   2       BBV

                                   3       CVB

sas_9
Obsidian | Level 7

Hi Linlin, i got one issue in my dataset. your code works perfect but i have more than one empname value in dataset. what i need to change for that?

eg;

empname

abc

abc

abc

bbv

bbv

cvb

cvb

cvb

cvb


Thanks.

Reeza
Super User

What do you mean you have more than one empname? More than one variable?

The fomula will work on the entire column, so all observations of one variable.

sas_9
Obsidian | Level 7

no, i mean more than one value for variable;

eg;

empname

abc

abc

abc

bbv

bbv

cvb

cvb

cvb

cvb

Reeza
Super User

LinLin's code should work regardless.

If it doesn't, post the code you used and the log, with a print of the output that doesn't work.

sas_9
Obsidian | Level 7

so if i have value ABC 50 times (for variable empname) in dataset then i have to mention it 50 times in card - is that right?

Reeza
Super User

Mention what 50 times? ABC or the upcase function?

Note LinLin's code thoroughly. She first imports the data AS IS. A second datastep converts the empname to upcase, and a second dataset is created.

sas_9
Obsidian | Level 7

50 times ABC...

EMPNAME

ABC

ABC

ABC

.

.
.

ABC

Astounding
PROC Star

Sandy,

It's time for a break.  You've been working too hard.

If you wanted to assign X=1, you would just add the statement:

data want;

set have;

X=1;

run;

You wouldn't have to add it 50 times, just because you have 50 observations in your data set.  Similarly, you could code:

data want;

set have;

empname = upcase(empname);

run;

It changes EMPNAME for every observation in your data set.  You don't need to know how many observations you have, or what the values of EMPNAME are.  The statement just executes for every observation.

Reeza
Super User

In QueryBuilder add a computed column.

Use the function upper or upcase to create a new variable that is upcase.

sas_9
Obsidian | Level 7

Thanks Linlin and Reeza...appreciate your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 11 replies
  • 3910 views
  • 0 likes
  • 4 in conversation