data have;
input name $ level;
cards;
Frank 1
Joan 2
Sui 2
Jose 3
Burt 4
Kelly .
Juan 1
run;
data want;
set work.levels;
if level=. then exp="unknown";
else if level=1 then exp="Low";
else if level = 2 or 3 then exp="Medium";
else exp="High";
run;
Which of the following is correct
A)Low,Medium,High
B)Low,Medium,High,Unknown
C)Low,Medium,High,Unknown and high
D)Low,Medium,High,Unknown, high, and (missing character values)
Answer : B
Could someone please suggest why it is B not C.. Many thanks in advance.
I'm happy to answer, but you do have to ask a question. Where in your post is a question? You have the multiple choice answers but no actual question posted.
Exact Question:
I can only respond to what I see posted, the code is incorrect and would not run, not sure why it's a problem to say that when it's clearly true. How am I supposed to know if that's part of the question or if it's a mistake you made? I can only see what you've posted.
@rajeshalwayswel wrote:
@reeza if you don't want to answer please won't reply to the question someone
will answer in a hurry I didn't check the code. This is my code
change your code to below level = 3 is missing. becacuase there is no "high" assigned and change your dataset name in set statement to have instead of levels
data want;
set work.have;
if level=. then exp="unknown";
else if level=1 then exp="Low";
else if level = 2 or level = 3 then exp="Medium";
else exp="High";
run;
because you have "High" not "high" in your else statement.
else if level = 2 or 3 then exp="Medium";
change it to
else if level = 2 or level = 3 then exp="Medium";
1. The code is wrong and would never run - it refers to the wrong data set
2. What is the question that is being asked? That's not anywhere in the post.
3. Why not run it and check the answer?
This exact or very similar question has been asked before, if you search you'll likely find the answer to whatever the question is and the logic. None of the answers are correct as the code posted won't run and HIGH will never be assigned.
@rajeshalwayswel wrote:
data have;
input name $ level;
cards;
Frank 1
Joan 2
Sui 2
Jose 3
Burt 4
Kelly .
Juan 1
run;
data want;
set work.levels;
if level=. then exp="unknown";
else if level=1 then exp="Low";
else if level = 2 or 3 then exp="Medium";
else exp="High";
run;
Which of the following is correct
A)Low,Medium,High
B)Low,Medium,High,Unknown
C)Low,Medium,High,Unknown and high
D)Low,Medium,High,Unknown, high, and (missing character values)
Answer : B
Could someone please suggest why it is B not C.. Many thanks in advance.
@reeza if you don't want to answer please won't reply to the question someone
will answer in a hurry I didn't check the code. This is my code
data have;
input name $ level;
cards;
Frank 1
Joan 2
Sui 2
Jose 3
Burt 4
Kelly .
Juan 1
;
run;
data want;
set have;
if level=. then exp="unknown";
else if level=1 then exp="Low";
else if level = 2 or 3 then exp="Medium";
else exp="High";
run;
Even with this correction, you have errors in the program that make it difficult to figure out what you are looking for.
You can get "unknown" but you can't get "Unknown" because that doesn't exist in your program.
You can get "High" but you can't get "high" because that doesn't exist in your program.
The way you typed the program, you would actually get:
"unknown", "Low" and "Medium" which is not one of the choices you presented. You can see that easily enough by testing your own program. Type in the question correctly, and you can get a better answer.
I'm happy to answer, but you do have to ask a question. Where in your post is a question? You have the multiple choice answers but no actual question posted.
Exact Question:
I can only respond to what I see posted, the code is incorrect and would not run, not sure why it's a problem to say that when it's clearly true. How am I supposed to know if that's part of the question or if it's a mistake you made? I can only see what you've posted.
@rajeshalwayswel wrote:
@reeza if you don't want to answer please won't reply to the question someone
will answer in a hurry I didn't check the code. This is my code
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.