SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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