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 find the median (without use of median func...

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-17-2013 11:30 PM

Not completely sure how to use the 'retain' and/or 'sum' statements or if they even apply.

patient ID | pulse rate | Blood Pressure |

pt013085 | 60 | 111 |

pt013086 | 58 | 121 |

pt013083 | 63 | 99 |

pt013080 | 62 | 109 |

pt013089 | 67 | 143 |

pt013088 | 65 | 119 |

pt013087 | 75 | 112 |

pt013081 | 70 | 117 |

pt013082 | 74 | 139 |

pt013084 | 73 | 151 |

pt013015 | 90 | 198 |

pt013025 | 102 | 87 |

pt013035 | 50 | 123 |

pt013045 | 110 | 165 |

pt013555 | 40 | 145 |

pt123456 | 67 | 99 |

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

Posted in reply to felipeespi

05-18-2013 12:47 AM

proc means with median.

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

Posted in reply to Reeza

05-18-2013 10:45 AM

Thanks man. I know the proc means with the median option but I wanted help on trying to figure it out

with the use of retain and sum statements in other words through the use of 'brute force'.

I appreciate any help

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

Posted in reply to felipeespi

05-18-2013 03:38 PM

You need to define what's a median to you, specifically if you have even number of observations.

Sum is not required to calculate median, retain/lag may or may not be helpful depending on your methodology.

You do need to sort your data set first, find the number of obs. If odd, take the middle value, you can use point in a data step.

If even then it depends on your method, usually an average, so then two point statements in a datastep would work.

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

Posted in reply to Reeza

05-18-2013 04:11 PM

I forgot to mention that the median would be for the Blood pressure variable and to be saved in another variable median_1 in excel I'm trying to apply your comments but I'm going nuts.

Thanks again

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

Posted in reply to felipeespi

05-18-2013 05:18 PM

Explain why you can't use proc means or standard procs. Otherwise it sounds like homework, which I don't feel inclined to help with.

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

Posted in reply to Reeza

05-18-2013 05:42 PM

Competition between coworkers where one claims to be able to find the median without using standard (faster/more comprehensive) methods like proc means, univariate, etc.

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

Posted in reply to felipeespi

05-18-2013 12:04 PM

This is quite simple. Consider the ingredients:

NOBS option to SET statement

_N_ automatic variable

and answer the question : Where do you expect the median value to be in a sorted dataset?

PG

PG