BookmarkSubscribeRSS Feed
Hello_there
Lapis Lazuli | Level 10
data have;
infile datalines dsd dlm=",";
	input method $ stand_ $ rdr $ cnt1 cnt2 cnt3;
datalines;
a, pos, neg, 34, 29, 15
a, pos, neg, 32, 21, 19
a, neg, pos, 21, 39, 49
a, neg, neg, 20, 38, 32
;
run;

Hi, I'm trying to have it so that I can calculate true positive, false negative, false positive, and true negative.

How would I go about doing this to create a 3 new columns with 4 rows called val1 val2 val3? 

So for example, I would have to do

obs.   val1                  val2                   val3

 1        34/(34+21).     29/(29+39)      15/(15+49)

2.       32/(32+20).      21/(21+38)

3.       21/(34+21)

4.  

2 REPLIES 2
ballardw
Super User

If the only data you have is what you show then do it by hand.

 

Otherwise you need to provide some more details. How do we know what value to pick as any of those denominators? How to pick the numerator?

 

Or define exactly what a "true positive, false negative, false positive, and true negative" may be using general rules.

This is one of those cases that you know a lot more (hopefully) about your data than we do and so are skipping some steps that you think are obvious. To code a solution we need to know the generic rules to apply to any data. A specific example without any description of why which values are placed where in your calculation is nearly meaningless.

 

IF what you show is the result of summarizing another data set it may well be that other pre-summarized data is actually what we need to work with.

 

Your rules should also state what the role of the Method variable might be. You don't mention why it is there at all. If it will affect the calculations we need to know how.

Hello_there
Lapis Lazuli | Level 10
Hi, thanks for taking time to explain the information I'm missing from the perspective of someone trying to answer the question. You're right, there is not enough details to answer this question. Fortunately, I was able to code it using a macro that dealt with the tedious calculations.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 649 views
  • 1 like
  • 2 in conversation