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:
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.)
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;
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.
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.;
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;
Great - thank you so much!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.