turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- How to do complex(ish) calculations with variable ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

05-21-2014 06:00 PM

Hello,

I have a dataset that gives scores for each individual:

ID | Cat1 | Cat 2 |
---|---|---|

22245 | 1 | 1 |

54515 | 5 | 1 |

54515 | 3 | 4 |

I need two different levels of data from these scores:1, the frequencies of each (for cat1 and cat2), 1-5, which I easily get with Proc Freq, and 2) a calculated summary scores using the following equation and a variation (one for each of cat1 and cat2): (**3+4)/(1+2+3+4) **

1 | 14 | 0.33 | 14 | 0.33 |
---|---|---|---|---|

2 | 1057 | 25.08 | 1071 | 25.42 |

3 | 511 | 12.13 | 1582 | 37.54 |

4 | 859 | 20.38 | 2441 | 57.93 |

5 | 1773 | 42.07 | 4214 | 100.00 |

If I export my Proc Freq then I have a nice dataset that looks like the above table, but I don't know how to get this into another dataset or table that calculates my final score.

Thoughts?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to lynnem

05-21-2014 06:35 PM

Where is the 1+2+3+4 coming from?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

05-22-2014 09:50 AM

Those are the observation numbers. The calculation will look like this, filling in the frequencies for the observation numbers:

(511+859)/(14+1057+511+859) = 1370/2441 = 0.5612

Is there a way to automate that calculation so that I can export it and any other calculations into another dataset?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to lynnem

05-22-2014 10:11 AM

I can't be 100% sure because you have two sets of sample data that don't match up and that's confusing me.

I think you may want to look into the multi label format and proc tabulate which will calculate these for you automatically.

This is under the assumption you want a standard proc freq, but then some pre defined categories as well,

For example, your data has values 1, 2, 3,4 and you want to count how many 1, 2, 3, 4 and 3/4 together.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to lynnem

05-22-2014 10:23 AM

data have; input a b c d e; cards; 1 14 0.33 14 0.33 2 1057 25.08 1071 25.42 3 511 12.13 1582 37.54 4 859 20.38 2441 57.93 5 1773 42.07 4214 100.00 ; run; data var(keep=var1 var2); set have ; array x{4} _temporary_; array y{4} _temporary_; x{_n_}=b; y{_n_}=d; if _n_ eq 4 then do; var1=(x{3}+x{4})/sum(of x{*}) ; var2=(y{3}+y{4})/sum(of y{*}) ; output; stop; end; run;

Xia Keshan