Hi,
I have a column - city within a dataset that displays the city a client lives. But some cities are recorded in upper case , some in lower case and some in mixed case so when i try to run the frequency on cities, the same city is counted twice if recorded in different cases for example, london may be recorded as :
LONDON
london
Londnon
lonDON
so what statement can i use to change all the example to just one city in Uppercase i.e LONDON within the data set?
Thanks
Exactly, just use upcase() to convert your variable to upper case. Such as:
data have;
input city $;
cards;
LONDON
london
Londnon
lonDON
;
data want;
set have;
city=upcase(city);
run;
proc print;run;
Regards,
Haikuo
Thanks Haikuo,
But london is not the only city that was just an example . I have hundreds of cities in the data set, it actually contains about 100 000 records, so i may not be able to use the CARDS statement.
The cards statement just represents some sample data just to describe this example.
Just replace have in the second step to whatever table you already got data in, and skip step 1.
Thanks!
If you just want to use PROC FREQ on the variable then use the $UPCASE function.
proc freq data=have;
tables city;
format city $upcase.;
run;
If you want to fix the data then use the upcase() function in a data step as Haikuo as pointed out.
Thanks!
Here is a simple way which can change all alpha character into UPPERCASE.
filename tran 'c:\temp.dat'; proc cport data=sashelp.class file=tran outtype=upcase; run; proc cimport infile=tran data=want; run;
Ksharp
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.
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.