BookmarkSubscribeRSS Feed
Navaneethan6
Calcite | Level 5

Hi Team, I am practicing for the SAS base certification I have a scenario question which share by friend, I start to write the program for that I can't understand some points in the question. could please help to understand that.

 

1. Create data set ‘scoredata0’ from importing the excel data ‘score_data_miss777’
2. In data step,
a. create a new data set ‘scoredata1’ from ‘scoredata0’ using set statement
b. convert 777 in variables Score1,2,3 to missing (periods) using if… then … else statement
c. calculate average of scores using SAS function MEAN
d. using the calculated average score to create Grade categories A, B, C, D, F
3. Print data ‘scoredata1’ using Proc Print.

I can't understand the option b and don't know how to write the code for option d.

code I tried is below. 
proc import datafile="/home/u62129231/EPG1V2/SAS P 1/score_data_miss777.xlsx" 
dbms=xlsx out=scoredata0 replace;
run;
 
data scoredata1;
set work.scoredata0;
 
if score1=. then
do;
score1=777;
end;
 
if score2=. then
do;
score2=777;
end;
 
if score3=. then
do;
score3=777;
end;
 
run;
 
proc means data=scoredata1;
run;
 
proc print data=scoredata1;
run;


 

8 REPLIES 8
PaigeMiller
Diamond | Level 26

Your code does not do

 

convert 777 in variables Score1,2,3 to missing (periods) using if… then … else statement

 

Instead it does things the other way around, it converts missing to 777.

--
Paige Miller
Navaneethan6
Calcite | Level 5

Is Now my code is correct ?

 

proc import datafile="/home/u62129231/EPG1V2/SAS P 1/score_data_miss777.xlsx"
dbms=xlsx out=scoredata0 replace;
run;

data scoredata1;
set work.scoredata0;

if score1=777 then
do;
score1=.;
end;

if score2=777 then
do;
score2=.;
end;

if score3=777 then
do;
score3=.;
end;

run;

proc means data=scoredata1;
run;

proc print data=scoredata1;
run;

PaigeMiller
Diamond | Level 26

@Navaneethan6 wrote:

Is Now my code is correct ?


Test it yourself.

--
Paige Miller
Navaneethan6
Calcite | Level 5

Yeah, I will definitely test the code, but I need to under the question. should I need to do those 777 values as missing values right?  

PaigeMiller
Diamond | Level 26

@Navaneethan6 wrote:

Yeah, I will definitely test the code, but I need to under the question. should I need to do those 777 values as missing values right?  


I don't understand your question.

--
Paige Miller
Tom
Super User Tom
Super User

@Navaneethan6 wrote:

Yeah, I will definitely test the code, but I need to under the question. should I need to do those 777 values as missing values right?  


Answer this question.   When assigning letter grades do you use the class's average score? Or do you use the average score for an individual student in the class?

andreas_lds
Jade | Level 19

"c. calculate average of scores using SAS function MEAN"

>> you need to use the mean-function inside the data step, not the mean procedure

 

"d. using the calculated average score to create Grade categories A, B, C, D, F"

>> hardly possible without knowing which score to map to which letter. With the information a format or if-then-else could be used or a select-block.

Tom
Super User Tom
Super User

I think that they want you to do 2a to 2d in a single data step. 

 

Also did they provide a rule for converting an average score into a letter grade?  What scores should considered an A? etc.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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