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

Hi guys,

 

I just got a question, need your help: letter case in SAS seems making difference, at least in the case of "if...(then)".  Look at this example:

 

data _t_;
input ID Name$ bloodtype$ Weight;
if bloodtype='a'; 
cards;
3 kelly a 120
4 brown A 200
;
run;

 

the result has only 1 line (3 kelly a 120).

 

if I change 'a' to 'A', then I get another line (4 brown A 200).

 

both didn't give me a result of all 2 lines.

 

does this mean, in some cases, letter case matters?

 

thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

In your code case doesn't matter. 

For variable values then it does matter.

 

This means you can do the following and it won't make a difference:

 

prOC MEAns data=SAShelP.ClasS;
ruN;

But when testing strings and comparison, then a variable value of 'a' is different than 'A'

 

if var1='a' then ...;

 

is different than

 

if var1='A' then..;

 

Solution, when making string comparisons, upcase or lowcase the strings before comparison.

 

if upcase(var1)='A' then..

View solution in original post

2 REPLIES 2
Reeza
Super User

In your code case doesn't matter. 

For variable values then it does matter.

 

This means you can do the following and it won't make a difference:

 

prOC MEAns data=SAShelP.ClasS;
ruN;

But when testing strings and comparison, then a variable value of 'a' is different than 'A'

 

if var1='a' then ...;

 

is different than

 

if var1='A' then..;

 

Solution, when making string comparisons, upcase or lowcase the strings before comparison.

 

if upcase(var1)='A' then..
mich_ard
Fluorite | Level 6
thank Reeza for quick reply, your answer works. I confused code case and value case. I'm a newbie.

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 891 views
  • 2 likes
  • 2 in conversation