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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.