Hi guys.. A very simple example below, where I create some test data such that Origin has both the character values Europe and EUROPE.
data test;
set sashelp.cars;
if type = 'Sedan' and Origin = 'Europe' then Origin = 'EUROPE';
run;
proc means data = test;
class Origin;
var Weight;
run;
When I run the proc means, can I make SAS interpret the class variable case insensitive?
Regards
Yes. In general you can define a SAS format that collapses all of the possible choices into a single formatted value.
For your example, you don't need to create a custom format because the $UPCASE. format converts all values to uppercase:
proc means data = test;
format Origin $UPCASE.;
class Origin;
var Weight;
run;
Well, in my opinion, this is a data modelling question rather than a coding one. What you want to end up with is a dataset contianing consistent data. Generally I like to see a dataset where textual elements contain a code as well, so in the one below you would have a step which codes all possible combinations of data element xyz to a consitent manner (be that a number or shortened code text.
So, you would code your country column based on given rules such as country in (upcase()=EUROPE, EUR, EU) all equal 1 (or EU or something).
As for your question, not sure how you would make a procedure know all the connotations of the data which only you know. As above, you state Europe=EUROPE, but what about EU which is another common abbreviation.
Yes. In general you can define a SAS format that collapses all of the possible choices into a single formatted value.
For your example, you don't need to create a custom format because the $UPCASE. format converts all values to uppercase:
proc means data = test;
format Origin $UPCASE.;
class Origin;
var Weight;
run;
Thank you all for your advice and happy holidays 🙂
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.