BookmarkSubscribeRSS Feed
mpc5
Calcite | Level 5

This assignment is overwhelming, any assistance will help!

 

Use the RANUNI function in conjunction with a DO loop and an OUTPUT statement to create a temporary SAS data set called agree containing 100 observations and two character variables called rater1 and rater2. (We'll use the data set to calculate the Kappa coefficient between the two raters.) Now, here are the specific requirements for the problem:

  • Use a seed of 456 in your RANUNI function so that we all create the same data set.

  • For each iteration of the DO loop:
    • (1) if the value returned by the RANUNI function is less than 0.4, set rater1 to equal Yes and rater2 to equal Yes
    • (2) if the value returned by the RANUNI function is at least 0.4, but less than 0.5, set rater1 to equal Yes and rater2 to equal No
    • (3) if the value returned by the RANUNI function is at least 0.5, but less than 0.6, set rater1 to equal No and rater2 to equal Yes
    • (4) if the value returned by the RANUNI function is at least 0.6, set rater1 to equal No and rater2 to equal No.

  • Write the code using three macro variables called cutoff1cutoff2, and cutoff3 so that the cutoff values of 0.4, 0.5, and 0.6 could be changed easily.

  • Compute the Kappa coefficient between the two raters.

What is the Kappa coefficient when the cutoff values are set at 0.4, 0.5, and 0.6?
What level of agreement does it suggest exists between the two raters?
What is the Kappa coefficient when the cutoff values are set at 0.2, 0.5, and 0.8?
What level of agreement does it suggest exists between the two raters then? (Hint: I recommend first getting the code to work using the values 0.4, 0.5, and 0.6. Then replace those values with the cutoff1cutoff2, and cutoff3 macro variables.)

8 REPLIES 8
ballardw
Super User

And the question is?

What have you tried so far?

 

I don't know your instructor but using values of "Yes" and "No" is sub-optimal coding.

 

 

mpc5
Calcite | Level 5


DATA agree;
DO units = 1 to 100;
Random = RANUNI (456);
OUTPUT;
END;
RUN;

ballardw
Super User

@mpc5 wrote:


DATA agree;
DO units = 1 to 100;
Random = RANUNI (456);
OUTPUT;
END;
RUN;


Reasonable start.

So now I expect the teacher wants some If/then/else statements to assign the values for the Rater variables. They would come before the Output statement.

mpc5
Calcite | Level 5

can a "THEN" statement equal more than one response?

example this is what i have for the first if then statement;

IF _N_ lt 0.4 then rater1= 'Yes' and rater2= 'Yes';

Tom
Super User Tom
Super User

Use a DO/END block to execute multiple statements.

if (condition) then do;
  statement1;
  statement2;
end;
mpc5
Calcite | Level 5

This is what I have so far, NEED HELP:

 

DATA agree;
DO units = 1 to 100;
Random = RANUNI (456);

IF _N_ lt 0.4 then rater1= 'Yes' and rater2= 'Yes';
ELSE IF _N_ ge 0.4 and lt 0.5 then rater1= 'Yes' and rater2= 'No';
ELSE IF _N_ ge 0.5 and lt 0.6 then rater1= 'No' and rater2= 'Yes';
ELSE IF _N_ ge 0.6 then rater1= 'No' and rater2= 'No';
OUTPUT;
END;
RUN;

%MACRO agreecuts (cutoff=);
DATA agree;
set agree;
RUN;

%MEND;

%AGREECUTS(cutoff= 0.4)
%AGREECUTS(cutoff= 0.5)
%AGREECUTS(cutoff= 0.6)

 

 

HERE IS MY LOG:

75
76 DATA agree;
77 DO units = 1 to 100;
78 Random = RANUNI (456);
79
80 IF _N_ lt 0.4 then rater1= 'Yes' and rater2= 'Yes';
81 ELSE IF _N_ ge 0.4 and lt 0.5 then rater1= 'Yes' and rater2= 'No';
---
388
200
82 ELSE IF _N_ ge 0.5 and lt 0.6 then rater1= 'No' and rater2= 'Yes';
---- ---
160 388
200
83 ELSE IF _N_ ge 0.6 then rater1= 'No' and rater2= 'No';
----
160
ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.

ERROR 160-185: No matching IF-THEN clause.

84 OUTPUT;
85 END;
86 RUN;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
80:48 81:48 82:48 83:48
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.AGREE may be incomplete. When this step was stopped there were 0
observations and 5 variables.
WARNING: Data set WORK.AGREE was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.04 seconds


87
88 %MACRO agreecuts (cutoff=);
89 DATA agree;
90 set agree;
91 RUN;
92
93 %MEND;
94
95 %AGREECUTS(cutoff= 0.4)

NOTE: There were 0 observations read from the data set WORK.AGREE.
NOTE: The data set WORK.AGREE has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


96 %AGREECUTS(cutoff= 0.5)

NOTE: There were 0 observations read from the data set WORK.AGREE.
NOTE: The data set WORK.AGREE has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


97 %AGREECUTS(cutoff= 0.6)

NOTE: There were 0 observations read from the data set WORK.AGREE.
NOTE: The data set WORK.AGREE has 0 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

 

Reeza
Super User

If you add a comment to your code for every line I'll help you with the answer. 

Put a comment with what you think each line is doing.

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
  • 776 views
  • 0 likes
  • 4 in conversation