BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mcypert16
Calcite | Level 5
data work.expertise;

INPUT ID Name $ Level;
	if level = . then expertise = 'Unknown';
	else if level = 1 then expertise = 'Low';
	else if level = 2 or 3 then expertise = 'Medium';
	else expertise = 'High';

DATALINES;
1 Frank 1
2 Joan 2
3 Sui 2
4 Jose 3
5 Burt 4
6 Kelly .
7 Juan 1
;
run;

I see what the problem is right away.  else if level = 2 or 3 then expertise = 'Medium';  It should be level=2 OR level=3.  

 

What I don't understand is the code produces this output?  Any explanation would be nice.  Thanks.

 

Screen Shot 2016-03-05 at 1.56.56 PM.png 

1 ACCEPTED SOLUTION

Accepted Solutions
4 REPLIES 4
Reeza
Super User

@mcypert16 May I ask where these questions are coming from?

mcypert16
Calcite | Level 5

Yes.  They are from a website called  BI exam academy.  I understand the question now.  The else if level=2 or 3 is always true because 3 is nonmissing and not 0.  So the code never gets past line 3.  

 

 

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
  • 4 replies
  • 896 views
  • 0 likes
  • 3 in conversation