BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
cosmid
Lapis Lazuli | Level 10

Hi, 

 

My answer for Question 6 won't match with the practice question below from SAS official website.I keep getting 1557 for Question 6.

 

Below is a practice question from SAS official website:

Project 3: This project will work with the following program:

data work.lowchol work.highchol;

  set sashelp.heart;

  if cholesterol lt 200 output work.lowchol;

  if cholesterol ge 200 output work.highchol;

  if cholesterol is missing output work.misschol;

run;

 

This program is intended to:

  • Divide the observations of sashelp.heart into three data sets, work.highchol, work.lowchol, and work.misschol

  • Only observations with cholesterol below 200 should be in the work.lowchol data set.

  • Only Observations with cholesterol that is 200 and above should be in the work.highchol data set.

  • Observations with missing cholesterol values should only be in the work.misschol data set.

 

Fix the errors in the above program. There may be multiple errors in the program. Errors may be syntax errors, program structure errors, or logic errors. In the case of logic errors, the program may not produce an error in the log. After fixing all of the errors in the program, answer the following questions:

Question 5: How many observations are in the work.highchol data set?

Answer: 3652

Question 6: How many observations are in the work.lowchol data set?

Answer: 1405

 

My version of the corrected code:

data work.lowchol work.highchol work.misschol.;

  set sashelp.heart;

  if cholesterol lt 200 then output work.lowchol;

  if cholesterol ge 200 then output work.highchol;

  if cholesterol = . then output work.misschol;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

Hello,

 

Missing is lower than any "valid" value.

You need this :

data work.lowchol work.highchol work.misschol;
  set sashelp.heart;
  if      cholesterol = .    then output work.misschol; 
  else if cholesterol lt 200 then output work.lowchol;
  else if cholesterol ge 200 then output work.highchol;
  else;
run;
/* end of program */

Cheers,

Koen

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

I'm kind of lost here,@cosmid. Did you run your fixed code? Were there SAS errors? Did it give the correct answer? If not, what is wrong with the answer? Can you please clear this up?

 

I'm also going to give the people at SAS a big thumbs down for writing such a poor question.

 

Only observations with cholesterol below 200 should be in the work.lowchol data set.

• Only Observations with cholesterol that is 200 and above should be in the work.highchol data set.

• Observations with missing cholesterol values should only be in the work.misschol data set.

 

So missing is less than 200, these should "only" be in the lowchol data set. But later it says missing should "only" be in the misschol data set. So ... This is contradictory. Both of these "only" conditions cannot be satisfied. I don't even know what the right answer is.

--
Paige Miller
cosmid
Lapis Lazuli | Level 10
Hi,

Sorry it wasn't clear. That's exactly what the question was. But with sbxkoenk's solution, the answer did match the answer key.

sbxkoenk
SAS Super FREQ

Hello,

 

Missing is lower than any "valid" value.

You need this :

data work.lowchol work.highchol work.misschol;
  set sashelp.heart;
  if      cholesterol = .    then output work.misschol; 
  else if cholesterol lt 200 then output work.lowchol;
  else if cholesterol ge 200 then output work.highchol;
  else;
run;
/* end of program */

Cheers,

Koen

cosmid
Lapis Lazuli | Level 10
Thanks again Koen!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 1448 views
  • 1 like
  • 3 in conversation