LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 16 Sep 2007 08:39:09 -0400
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Calculate percentages of a subsample
Comments: To: Haigang Zhou <hzhou3@UNLSERVE.UNL.EDU>

Haigang,

I apparently misunderstood what you're asking for, as my results are slightly different than those shown in your example.

Regardless, there are numerous ways to get what you want, including:

data temp; merge one (rename=(value=cutoff)) two; by id; if value gt cutoff then test="higher"; else test="lower"; run;

proc freq data=temp; tables test/out=want ( drop=count where=(test eq "higher")); by id; run;

I'd use proc freq so that you can easily control whether you want missing values included in the calculations and/or overall percentages

HTH, Art --------- On Sun, 16 Sep 2007 06:35:42 -0400, Haigang Zhou <hzhou3@UNLSERVE.UNL.EDU> wrote:

>I want to calculate the percentages of values in dataset2 that are larger >than the pre-specied value in dataset1 grouped by id. > >data one; > input value id; > cards; > -.1 150 > 2 1150 > ; >data two; > input value id; > cards; >-2.02301487 150 >1.160065383 150 >0.134215614 150 >1.87326498 150 >1.214724878 150 >0.278588803 1150 >2.090436399 1150 >0.192193627 1150 >1.771033228 1150 >2.009589141 1150 >; >run; > >I want to have a dataset contains the following result. > >ID percent >-------------- >150 80% >1150 60% > >Any help is appreciated.


Back to: Top of message | Previous page | Main SAS-L page