Dear All:
This is the dataset i have ..
data have ;
input pat $ Dep $ rel $ out $ ds $ ;
cards;
123 CLI MIL RES AE
123 CLI MOD RES DS
345 DMA SEV NOT AE
345 DMA SEV RES DS
;
run;
Pat and Dep being the key variables , if the values for
variables(Rel,out) match per pat and per Dep , they must be set to
missing ,
below is the output that i am looking for ...
Pat Dep Rel out ds
123 CLI MIL AE
123 CLI MOD DS
345 DMA NOT AE
345 DMA RES DS
Thanks in Advance
Al
|
|
0
|
|
|
|
Reply
|
ali6058 (166)
|
6/22/2010 11:40:54 PM |
|
Al,
Your description doesn't match your desired output. However, if the
following is what you want and your data are already sorted by pat Dep
out, then the following code might do what you want:
data want (drop=3Dgotone);
set have;
retain gotone;
by pat Dep out;
if first.out then do;
gotone=3D0;
if not last.out then do;
gotone=3D1;
call missing(out);
end;
end;
else if gotone then call missing(out);
run;
HTH,
Art
--------------
On Jun 22, 7:40=A0pm, Al <ali6...@gmail.com> wrote:
> Dear All:
>
> This is =A0the dataset i have ..
>
> data have ;
> input pat $ Dep $ rel $ out $ ds $ ;
> cards;
> 123 CLI MIL RES AE
> 123 CLI MOD RES DS
> 345 DMA SEV NOT AE
> 345 DMA SEV RES DS
>
> ;
> run;
>
> Pat and Dep being the key variables , =A0if the values for
> variables(Rel,out) match per pat and per Dep , they must be set to
> missing ,
>
> below is the output that i am looking for ...
>
> Pat Dep =A0Rel =A0 =A0out =A0 ds
> 123 CLI =A0 MIL =A0 =A0 =A0 =A0 =A0AE
> 123 CLI =A0 MOD =A0 =A0 =A0 =A0DS
> 345 DMA =A0 =A0 =A0 NOT =A0AE
> 345 DMA =A0 =A0 =A0 RES =A0DS
>
> Thanks in Advance
> Al
|
|
0
|
|
|
|
Reply
|
art297 (4237)
|
6/23/2010 3:58:35 AM
|
|
On Jun 22, 10:58=A0pm, Arthur Tabachneck <art...@netscape.net> wrote:
> Al,
>
> Your description doesn't match your desired output. =A0However, if the
> following is what you want and your data are already sorted by pat Dep
> out, then the following code might do what you want:
>
> data want (drop=3Dgotone);
> =A0 set have;
> =A0 retain gotone;
> =A0 by pat Dep out;
> =A0 if first.out then do;
> =A0 =A0 gotone=3D0;
> =A0 =A0 if not last.out then do;
> =A0 =A0 =A0 gotone=3D1;
> =A0 =A0 =A0 call missing(out);
> =A0 =A0 end;
> =A0 end;
> =A0 else if gotone then call missing(out);
> run;
>
> HTH,
> Art
> --------------
> On Jun 22, 7:40=A0pm, Al <ali6...@gmail.com> wrote:
>
>
>
> > Dear All:
>
> > This is =A0the dataset i have ..
>
> > data have ;
> > input pat $ Dep $ rel $ out $ ds $ ;
> > cards;
> > 123 CLI MIL RES AE
> > 123 CLI MOD RES DS
> > 345 DMA SEV NOT AE
> > 345 DMA SEV RES DS
>
> > ;
> > run;
>
> > Pat and Dep being the key variables , =A0if the values for
> > variables(Rel,out) match per pat and per Dep , they must be set to
> > missing ,
>
> > below is the output that i am looking for ...
>
> > Pat Dep =A0Rel =A0 =A0out =A0 ds
> > 123 CLI =A0 MIL =A0 =A0 =A0 =A0 =A0AE
> > 123 CLI =A0 MOD =A0 =A0 =A0 =A0DS
> > 345 DMA =A0 =A0 =A0 NOT =A0AE
> > 345 DMA =A0 =A0 =A0 RES =A0DS
>
> > Thanks in Advance
> > Al- Hide quoted text -
>
> - Show quoted text -
I apolozise if i dint explain the scenario right .. let me try one
more time .. for all the obserations with same pat ,dep values ..if
values rel and out fields are same they should be set to missing .. i
ran your code, the rel values for pat 345 are same but they were not
set to missing .
Thanks in advance
Al
|
|
0
|
|
|
|
Reply
|
ali6058 (166)
|
6/23/2010 4:43:20 AM
|
|
Al,
You could probably do what you want with two passes through your
data. For example:
data have ;
input pat $ Dep $ rel $ out $ ds $ ;
cards;
123 CLI MIL RES AE
123 CLI MOD RES DS
345 DMA SEV NOT AE
345 DMA SEV RES DS
;
data want (drop=3Dgotone);
set have;
retain gotone;
by pat Dep out notsorted;
if first.out then do;
gotone=3D0;
if not last.out then do;
gotone=3D1;
call missing(out);
end;
end;
else if gotone then call missing(out);
run;
data want (drop=3Dgotone);
set want;
retain gotone;
by pat Dep rel notsorted;
if first.rel then do;
gotone=3D0;
if not last.rel then do;
gotone=3D1;
call missing(rel);
end;
end;
else if gotone then call missing(rel);
run;
HTH,
Art
--------------
On Jun 23, 12:43=A0am, Al <ali6...@gmail.com> wrote:
> On Jun 22, 10:58=A0pm, Arthur Tabachneck <art...@netscape.net> wrote:
>
>
>
>
>
> > Al,
>
> > Your description doesn't match your desired output. =A0However, if the
> > following is what you want and your data are already sorted by pat Dep
> > out, then the following code might do what you want:
>
> > data want (drop=3Dgotone);
> > =A0 set have;
> > =A0 retain gotone;
> > =A0 by pat Dep out;
> > =A0 if first.out then do;
> > =A0 =A0 gotone=3D0;
> > =A0 =A0 if not last.out then do;
> > =A0 =A0 =A0 gotone=3D1;
> > =A0 =A0 =A0 call missing(out);
> > =A0 =A0 end;
> > =A0 end;
> > =A0 else if gotone then call missing(out);
> > run;
>
> > HTH,
> > Art
> > --------------
> > On Jun 22, 7:40=A0pm, Al <ali6...@gmail.com> wrote:
>
> > > Dear All:
>
> > > This is =A0the dataset i have ..
>
> > > data have ;
> > > input pat $ Dep $ rel $ out $ ds $ ;
> > > cards;
> > > 123 CLI MIL RES AE
> > > 123 CLI MOD RES DS
> > > 345 DMA SEV NOT AE
> > > 345 DMA SEV RES DS
>
> > > ;
> > > run;
>
> > > Pat and Dep being the key variables , =A0if the values for
> > > variables(Rel,out) match per pat and per Dep , they must be set to
> > > missing ,
>
> > > below is the output that i am looking for ...
>
> > > Pat Dep =A0Rel =A0 =A0out =A0 ds
> > > 123 CLI =A0 MIL =A0 =A0 =A0 =A0 =A0AE
> > > 123 CLI =A0 MOD =A0 =A0 =A0 =A0DS
> > > 345 DMA =A0 =A0 =A0 NOT =A0AE
> > > 345 DMA =A0 =A0 =A0 RES =A0DS
>
> > > Thanks in Advance
> > > Al- Hide quoted text -
>
> > - Show quoted text -
>
> I apolozise if i dint explain the scenario right .. let me try one
> more time .. for all the obserations with same pat ,dep values ..if
> values rel and out fields are same they should be set to missing .. i
> ran your code, the rel values for pat 345 are same but they were not
> set to missing .
>
> Thanks in advance
> Al- Hide quoted text -
>
> - Show quoted text -
|
|
0
|
|
|
|
Reply
|
art297 (4237)
|
6/23/2010 11:49:55 AM
|
|
Al, here is a two-step approach using PROC SQL.
data have ;
input pat $ dep $ rel $ out $ ds $ ;
cards;
123 CLI MIL RES AE
123 CLI MOD RES DS
345 DMA SEV NOT AE
345 DMA SEV RES DS
;
run;
/* Get the count of distinct "rel" and "out" values for each pat-dep
combination */
proc sql;
create table table1 as
select pat, dep, rel, out, ds, count(distinct rel) as c1,
count(distinct out) as c2
from have
group by pat, dep;
quit;
data table2 (drop =3D rel out c1 c2 rename =3D (rel2 =3D rel out2 =3D out))=
;
set table1;
by pat dep;
if c1 ne 1 then rel2 =3D rel;
else rel2 =3D .;
if c2 ne 1 then out2 =3D out;
else out2 =3D .;
run;
Hope this is helpful.
Sid
On Jun 22, 6:40=A0pm, Al <ali6058@gmail.com> wrote:
> Dear All:
>
> This is =A0the dataset i have ..
>
> data have ;
> input pat $ Dep $ rel $ out $ ds $ ;
> cards;
> 123 CLI MIL RES AE
> 123 CLI MOD RES DS
> 345 DMA SEV NOT AE
> 345 DMA SEV RES DS
>
> ;
> run;
>
> Pat and Dep being the key variables , =A0if the values for
> variables(Rel,out) match per pat and per Dep , they must be set to
> missing ,
>
> below is the output that i am looking for ...
>
> Pat Dep =A0Rel =A0 =A0out =A0 ds
> 123 CLI =A0 MIL =A0 =A0 =A0 =A0 =A0AE
> 123 CLI =A0 MOD =A0 =A0 =A0 =A0DS
> 345 DMA =A0 =A0 =A0 NOT =A0AE
> 345 DMA =A0 =A0 =A0 RES =A0DS
>
> Thanks in Advance
> Al
|
|
0
|
|
|
|
Reply
|
nsid31 (42)
|
6/23/2010 1:31:23 PM
|
|
|
4 Replies
176 Views
(page loaded in 0.553 seconds)
Similiar Articles: data structure, fread, find - comp.soft-sys.matlabHello What i am trying to is that read only numbers from the below data structure 0ÌÌÌÌ+2.650ÌÌÌÌ-29.005ÌÌÌÌ+2.325ÌÌÌÌ+36.89ÌÌÌÌ+34.26ÌÌÌÌ-37 ... Data Structure Using Proc Transpose - comp.soft-sys.sasHi All: This is the problem I am running in to when I try flipping the data using Proc transpose data work.have; infile datalines tru... SCSI CDB response data structure - comp.periphs.scsiHi, I'm working with a USB mass storage device that accepts SCSI commands, and I'm trying to understand what this device supports. Are there any softw... Stacks Queues and other data structures. - comp.lang.pascal.misc ...Before anyone asks, no I didnt go back to school, so it's not homework...:-) with what's available in the FCL and/or data structure coding practice ... Hierarchical data structure from a multi-dimensional array - comp ...Hi all, I would appreciate any help. I have a multi-dimensional array representing the column and row dimensions in a table and values in the t... get the data from struct - comp.soft-sys.matlab"sscnekro " <stiahni.mail@zoznam.sk> wrote in message <hup09f$f13$1@fred.mathworks.com>... > I don't really know to use structures, but maybe to start, here is ... puttygen: Couldn't load private key (unable to create key data ...puttygen: Couldn't load private key (unable to create key data structure) Tweet Speed-up the reading of large binary files with complex structures ...Hi, I am trying to read a large binary file where the data is structured in a known format composed by a variable number of blocks. Also, these blo... Time conversion from time_t format - comp.soft-sys.matlab ...I have data files time tagged with C standard "time_t" data structure, which I believe is just time in seconds after 1 Jan 1970 (I don't care about va... Load data/.mat-file in Simulink - comp.soft-sys.matlabHello all, I have a Matlab function which imports and uses data from a .mat file. This is held in an array of structures, with each structure holdi... Data structure - Wikipedia, the free encyclopediaIn computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. Different kinds of data ... List of data structures - Wikipedia, the free encyclopediaBoolean (for boolean values True/False) Char (for character values) Float (for storing real number values) Double (a larger size of type float) int (for integral or ... 7/30/2012 6:19:52 AM
|