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

I understand the RANUNI fuction but for the life of me I can't understand the three macro variables part of the question.  If you can help I would be extremely grateful!

 

In summary, your job here is to 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; and (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 cutoff1, cutoff2, 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 cutoff1, cutoff2, and cutoff3 macro variables.)

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Your code seems to be correct. Better try to run it.

Add RUN; to close the data step.

 

BTW, you can use format to assign the cutoffs instead IF ...THEN...; ELSE ...

proc format lib=work;
  value raterfmt
       1 = 'YES'
       2 = 'NO'
   ;
   vaulue cutoff
    low - &cutoff1 = '1'
   &cutoff1 - &cutoff2 = '2'
   &cutoff2 - &cutoff3 = '3'
   &cutoff3 - high = '4'
  ;
run;

data agree2;
  set agree1;
       rater1 = put(random, cutoff.);
       format rater1 raterfmt. ;
run;

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

To sort the results into 4 groups you have 3 cutoffs.

Using macro variable enables to assign values outside of the datastep,

thus changing cutoff values will be easy.

 

Use %LET cuttoff1=0.4;  to assign value to the 1st macro variable.

Then use &cutoff1 inside your datastep code instead the specific value,

like:   if  result < &cutoff1 then ...

 

If you still have issues post the code you wrote.

audreys
Calcite | Level 5

Thank you so much for your help!  This is the partial coding (part relevant with the macro).  Is this right?  I need to be able to create the second variable within the if / then statement.  Could there be an if/then/and ... else then... and repeat?

 

%LET cutoff1 = 0.4;
%LET cutoff2 = 0.5;
%LET cutoff3 = 0.6;

 


PROC FORMAT;
value raterfmt 1 = 'Yes'
2 = 'No';
RUN;

 

DATA agree2;
set agree1;
if random lt &cutoff1 then rater1=1;
else if random ge &cutoff1 and random le &cutoff2 then rater1=1;
else if random ge &cutoff2 and random le &cutoff3 then rater1=2;
else if random ge &cutoff3 then rater1=2;
format rater1 raterfmt.;

 

 

 

 

 

Shmuel
Garnet | Level 18

Your code seems to be correct. Better try to run it.

Add RUN; to close the data step.

 

BTW, you can use format to assign the cutoffs instead IF ...THEN...; ELSE ...

proc format lib=work;
  value raterfmt
       1 = 'YES'
       2 = 'NO'
   ;
   vaulue cutoff
    low - &cutoff1 = '1'
   &cutoff1 - &cutoff2 = '2'
   &cutoff2 - &cutoff3 = '3'
   &cutoff3 - high = '4'
  ;
run;

data agree2;
  set agree1;
       rater1 = put(random, cutoff.);
       format rater1 raterfmt. ;
run;
audreys
Calcite | Level 5

Great - thank you so much!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 1387 views
  • 0 likes
  • 2 in conversation