[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: proc summary
From:       "Dunn, Toby" <tdunn () TEA ! STATE ! TX ! US>
Date:       2004-04-30 12:57:10
[Download RAW message or body]

Try using:

proc summary data=modebyperson print;/*calculates per person avg by
mode*/
        var _freq_;
        class mode/missing;
        where _type_ =1;
        run;

HTH
Toby Dunn

-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Noreen McDonald
Sent: Thursday, April 29, 2004 8:10 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: proc summary

My dataset consists of travel records for multiple hhs (index variables
are hhid personid tripid).
 I would like to summarize the average number of trips per person by
mode (ie on avg, people make
1.5 auto trips per day).  I have used proc summary to address this
question and have run into a
problem.  Proc summary only generates _freq_ when the mode is used, ie
if I took no walk trips
than the walk mode would be omitted in the summary rather than
generating a 0 frequency.
 Obviously retaining the 0 frequency is essential to accurately
computing overall trip averages by
mode.

I have 1 solution to the problem.  I use a classdata set to force proc
summary to consider all
modes and generate 0 frequencies.  However I would ultimately like to
consider more than 1 class
variable, ie comparing avg # of trips by mode for men & women.
Therefore I would really prefer
not to have to create a classdata set for each possible combination of
class variables I might
come up with (especially since there are 27 possible modes-it gets big
quick). (I also dislike
having to use a by statement since it requires sorting, not an issue in
the following example, but
a problem with the real data).  I'm guessing there must be a simple
solution/command that forces
sas to consider all values of the class variable but I have not been
able to find it in the
documentation.  (Because the dataset is so large it would be impossible
to add 0 weight
observations in all modes to force consideration)

Below is my code for a very simplified example using my classdata
solution (actual dataset has
thousands of records).
TIA and apologies for such basic questions,
Noreen
data trial;/*I only consider 1 hh to simplify example*/
        input personid $ tripid $ mode $;
datalines;
01 01 A
01 02 B
01 03 A
02 01 A
02 02 W
;
data typesmode;
        input mode $;
datalines;
A
B
W
;
proc summary data=trial classdata=typesmode print;
        class mode;
        by personid;
        output out=modebyperson;
run;/*so the real question is how to force sas to generate 0 frequencies
for W (Person1) and B
(person2) without using the classdata option*/
proc summary data=modebyperson print;/*calculates per person avg by
mode*/
        var _freq_;
        class mode;
        where _type_ =1;
        run;


Noreen McDonald
Doctoral Candidate
Dept. of City & Regional Planning
UC Berkeley

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic