[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: Sum up variable
From: Ron Coleman <rcoleman () WORLDNET ! ATT ! NET>
Date: 1997-08-30 18:25:57
[Download RAW message or body]
Shaun Su wrote:
>
> Please help me with this, I basically want to sum the variable 'alivecnt'
> for each id and then graph this sum against diffd (or do a regression).
> But I am having trouble summing up the variable '1alivecnt'.
>
> >From the sample printout below, I would like to sum up alivecnt for each
> patient, then graph that against diffd. So, patient 1 would yield
> alivecnt of 3, diffd of 153.
> Patient 2 yields alivecnt of 8, diffd of 161, Patient 3 yield alivecnt of
> 3, diffd of 167.
>
> THANKS in advance.
>
> -shaun
> -------------------------- Patient identification number=1
> ---------------------------
> OBS FORM STATALL DIFFD ALIVECNT
> 2 2 1 153 1
> 3 3 1 . 1
> 4 4 1 . 1
> 5 5 9 . .
> 6 6 9 . .
> 7 7 4 . .
> -------------------------- Patient identification number=2
> ---------------------------
> OBS FORM STATALL DIFFD ALIVECNT
> 8 2 1 161 1
> 9 3 1 . 1
> 10 4 1 . 1
> 11 5 1 . 1
> 12 6 1 . 1
> 13 7 1 . 1
> 14 A 1 . 1
> 15 B 1 . 1
> -------------------------- Patient identification number=3
> ---------------------------
> OBS FORM STATALL DIFFD ALIVECNT
> 16 2 1 167 1
> 17 3 1 . 1
> 18 4 1 . 1
> 19 5 9 . .
> 20 6 9 . .
> 21 7 4 . .
> 22 8 2 . .
If the patient number is a part of the data set then you can use PROC
MEANS or SUMMARY to sum the observations then use PLOT or GPLOT to graph
the result.
data test;
input patient $1. form $ @10 statall $11. diffd alivecnt;
cards;
1 2 1 153 1
1 3 1 . 1
1 4 1 . 1
1 5 9 . .
1 6 9 . .
1 7 4 . .
2 2 1 161 1
2 3 1 . 1
2 4 1 . 1
2 5 1 . 1
2 6 1 . 1
2 7 1 . 1
2 A 1 . 1
2 B 1 . 1
3 2 1 167 1
3 3 1 . 1
3 4 1 . 1
3 5 9 . .
3 6 9 . .
3 7 4 . .
3 8 2 . .
;
run;
proc summary data=test nway;
class patient;
var diffd alivecnt;
output out=summary sum=;
run;
proc plot data=summary;
plot diffd*alivecnt=patient;
run;
--
Ron Coleman A SAS Quality Partner.
Links Analytical, Inc. Linking your data to your business!
3545-1 St. Johns Bluff Rd. Suite 300
Jacksonville FL 32224 mailto:rcoleman@worldnet.att.net
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic