02-20-2012 07:23 AM
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 :
so what statement can i use to change all the example to just one city in Uppercase i.e LONDON within the data set?
02-20-2012 07:36 AM
Exactly, just use upcase() to convert your variable to upper case. Such as:
input city $;
02-20-2012 07:46 AM
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.
02-20-2012 08:17 AM
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.
02-20-2012 09:00 AM
If you just want to use PROC FREQ on the variable then use the $UPCASE function.
proc freq data=have;
format city $upcase.;
If you want to fix the data then use the upcase() function in a data step as Haikuo as pointed out.
02-21-2012 03:39 AM
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;