| Date: | Mon, 13 Feb 2006 12:11:27 -0500 |
| Reply-To: | "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM> |
| Subject: | Re: adding observations when class variables are missing,
but are not missing data |
|---|
I'm going to modify the test data to get rid of the variables which have no
significance for this question and to introduce a second BEND level:
data currently;
input Bend SubSample Species CatchTtl;
cards;
39 1 999 0
39 2 062 1
39 3 999 0
39 4 028 1
39 5 062 1
39 6 999 0
39 7 999 0
99 0 000 9
;
Now create an inclusive crossing of SubSample and Species values for each
BRND:
proc sql;
create view zeroes as
select *, 0 as CatchTtl from
(select distinct Bend, SubSample from currently)
natural join
(select distinct Bend, Species from currently)
;
quit;
Finally blend in the actual data:
data want;
update zeroes currently;
by Bend SubSample Species;
run;
You get:
Sub Catch
Obs Bend Species Sample Ttl
1 39 28 1 0
2 39 62 1 0
3 39 999 1 0
4 39 28 2 0
5 39 62 2 1
6 39 999 2 0
7 39 28 3 0
8 39 62 3 0
9 39 999 3 0
10 39 28 4 1
11 39 62 4 0
12 39 999 4 0
13 39 28 5 0
14 39 62 5 1
15 39 999 5 0
16 39 28 6 0
17 39 62 6 0
18 39 999 6 0
19 39 28 7 0
20 39 62 7 0
21 39 999 7 0
22 99 0 0 9
On Fri, 10 Feb 2006 08:48:22 -0800, gilacypha
<schuyler.sampson@SBCGLOBAL.NET> wrote:
>below is a subset of a dataset i am currently working with.
>
> Sub Catch
>Obs Seg Season SetDate Bend Sample Species TNEFF Ttl
>
>14 8 ST 18APR2005 39 1 999 0.98 0
>15 8 ST 18APR2005 39 2 062 0.82 1
>16 8 ST 18APR2005 39 3 999 1.31 0
>17 8 ST 18APR2005 39 4 028 1.17 1
>18 8 ST 18APR2005 39 5 062 1.51 1
>19 8 ST 18APR2005 39 6 999 0.84 0
>20 8 ST 18APR2005 39 7 999 1.30 0
>
>
>i am trying to obtain the mean total catch of each species within a
>bend. the problem that i am having is trying to get species which were
>not caputerd in subsamples within a bend (not missing data within a
>bend).
>
>therefore, my question is ....how do i insert/create speceis
>observations that are not in one subsample, but do exist in subsequent
>subsamples within same bend.
>
>example of what i want the above to look like for bend:
>
> Sub Catch
>Obs Seg Season SetDate Bend Sample Species TNEFF Ttl
>
>14 8 ST 18APR2005 39 1 028 0.98 0
>15 8 ST 18APR2005 39 1 062 0.98 0
>16 8 ST 18APR2005 39 2 028 0.82 1
>17 8 ST 18APR2005 39 2 062 0.82 0
>18 8 ST 18APR2005 39 3 028 1.31 0
>19 8 ST 18APR2005 39 3 062 1.31 0
>20 8 ST 18APR2005 39 4 028 1.17 1
>21 8 ST 18APR2005 39 4 062 1.17 0
>22 8 ST 18APR2005 39 5 028 1.51 0
>23 8 ST 18APR2005 39 5 062 1.51 1
>24 8 ST 18APR2005 39 6 028 0.84 0
>25 8 ST 18APR2005 39 6 062 0.84 0
>26 8 ST 18APR2005 39 7 028 1.30 0
>27 8 ST 18APR2005 39 7 062 1.30 0
>
>i am a novice sas user so any information explaining the fucntion of
>the code would be greatly appreciated.
>
>thanks in advance
|