BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PeterClemmensen
Tourmaline | Level 20

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

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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;

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.  

Rick_SAS
SAS Super FREQ

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;
PeterClemmensen
Tourmaline | Level 20

Thank you all for your advice and happy holidays 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1650 views
  • 5 likes
  • 3 in conversation