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.
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
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
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.
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.
no, i mean more than one value for variable;
eg;
empname
abc
abc
abc
bbv
bbv
cvb
cvb
cvb
cvb
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.
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?
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.
50 times ABC...
EMPNAME
ABC
ABC
ABC
.
.
.
ABC
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.
In QueryBuilder add a computed column.
Use the function upper or upcase to create a new variable that is upcase.
Thanks Linlin and Reeza...appreciate your help.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.