I have a following dataset with variables (subject,visit,ctc):
subject visit ctc
--------------------------
10001 5 0
10001 6 1
10001 7 0
10002 2 1
10002 3 3
10002 4 0
10002 5 1
10003 5 4
10003 6 1
10003 7 0
I need a dataset where the first occurance of value of the variable "CTC"
should be either 0 or 1 of each patient should be preset. The final
dataset should be as below ( no proc repost please):
subject visit ctc
---------------------------
10001 5 0
10002 2 1
10003 6 1
Thanks. i am totally lost
|
|
0
|
|
|
|
Reply
|
need_sas_help (102)
|
11/19/2009 7:43:12 PM |
|
Tom
Do you mean that for the first visit of the subject, you only want the line if CTC is 0 or 1 or do you want the first 0/1 line for the subject.
My solutions are:
data have;
input subject visit ctc;
cards;
10001 5 0
10001 6 1
10001 7 0
10002 2 1
10002 3 3
10002 4 0
10002 5 1
10003 5 4
10003 6 1
10003 7 0
proc print;
run;
Data wanted1;
set have;
by subject;
if first.subject and ctc in(0,1) then output;
run;
proc print;
run;
Data wanted2;
set test;
by subject;
if first.subject then flag = 0;
if ctc in(0,1) then do;
if flag= 0 then output;
flag = 1;
retain flag;
drop flag;
end;
run;
Proc print;run;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom Smith
Sent: Thursday, November 19, 2009 2:43 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: A Sub setting question - I am totally Lost - help me plz
I have a following dataset with variables (subject,visit,ctc):
subject visit ctc
--------------------------
10001 5 0
10001 6 1
10001 7 0
10002 2 1
10002 3 3
10002 4 0
10002 5 1
10003 5 4
10003 6 1
10003 7 0
I need a dataset where the first occurance of value of the variable "CTC"
should be either 0 or 1 of each patient should be preset. The final
dataset should be as below ( no proc repost please):
subject visit ctc
---------------------------
10001 5 0
10002 2 1
10003 6 1
Thanks. i am totally lost
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.
|
|
0
|
|
|
|
Reply
|
nathaniel.wooding (1453)
|
11/19/2009 8:07:02 PM
|
|
proc sort data=3Dhave out=3Dwant;
by subject visit; where ctc in (0,1);
run;
data want2; set want;
by subject visit; if first.subject;
run;
On Nov 19, 2:43=A0pm, need_sas_h...@YAHOO.COM (Tom Smith) wrote:
> I have a following dataset with variables (subject,visit,ctc):
>
> subject =A0 =A0 visit =A0 =A0 =A0ctc
> --------------------------
> 10001 =A0 =A0 =A0 =A05 =A0 =A0 =A0 =A0 0
> 10001 =A0 =A0 =A0 =A06 =A0 =A0 =A0 =A0 1
> 10001 =A0 =A0 =A0 =A07 =A0 =A0 =A0 =A0 0
> 10002 =A0 =A0 =A0 =A02 =A0 =A0 =A0 =A0 1
> 10002 =A0 =A0 =A0 =A03 =A0 =A0 =A0 =A0 3
> 10002 =A0 =A0 =A0 =A04 =A0 =A0 =A0 =A0 0
> 10002 =A0 =A0 =A0 =A05 =A0 =A0 =A0 =A0 1
> 10003 =A0 =A0 =A0 =A05 =A0 =A0 =A0 =A0 4
> 10003 =A0 =A0 =A0 =A06 =A0 =A0 =A0 =A0 1
> 10003 =A0 =A0 =A0 =A07 =A0 =A0 =A0 =A0 0
>
> I need a dataset where the first occurance of value of the variable "CTC"
> should be =A0either 0 or 1 of each patient should be preset. The final
> dataset should be as below ( no proc repost please):
>
> subject =A0 =A0 visit =A0 =A0 =A0ctc
> ---------------------------
> 10001 =A0 =A0 =A0 =A05 =A0 =A0 =A0 =A0 0
> 10002 =A0 =A0 =A0 =A02 =A0 =A0 =A0 =A0 1
> 10003 =A0 =A0 =A0 =A06 =A0 =A0 =A0 =A0 1
>
> Thanks. i am totally lost
|
|
0
|
|
|
|
Reply
|
stickerr
|
11/19/2009 8:12:19 PM
|
|
Your program got me to thinking, where + subsetting if.
data need;
set have;
where ctc in(0,1);
by subject;
if first.subject;
run;
On 11/19/09, Nathaniel Wooding <nathaniel.wooding@dom.com> wrote:
> Tom
>
> Do you mean that for the first visit of the subject, you only want the line if CTC is 0 or 1 or do you want the first 0/1 line for the subject.
>
> My solutions are:
>
> data have;
> input subject visit ctc;
> cards;
> 10001 5 0
> 10001 6 1
> 10001 7 0
> 10002 2 1
> 10002 3 3
> 10002 4 0
> 10002 5 1
> 10003 5 4
> 10003 6 1
> 10003 7 0
> proc print;
> run;
> Data wanted1;
> set have;
> by subject;
> if first.subject and ctc in(0,1) then output;
> run;
> proc print;
> run;
> Data wanted2;
> set test;
> by subject;
> if first.subject then flag = 0;
> if ctc in(0,1) then do;
> if flag= 0 then output;
> flag = 1;
> retain flag;
> drop flag;
> end;
> run;
> Proc print;run;
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom Smith
> Sent: Thursday, November 19, 2009 2:43 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: A Sub setting question - I am totally Lost - help me plz
>
> I have a following dataset with variables (subject,visit,ctc):
>
> subject visit ctc
> --------------------------
> 10001 5 0
> 10001 6 1
> 10001 7 0
> 10002 2 1
> 10002 3 3
> 10002 4 0
> 10002 5 1
> 10003 5 4
> 10003 6 1
> 10003 7 0
>
> I need a dataset where the first occurance of value of the variable "CTC"
> should be either 0 or 1 of each patient should be preset. The final
> dataset should be as below ( no proc repost please):
>
> subject visit ctc
> ---------------------------
> 10001 5 0
> 10002 2 1
> 10003 6 1
>
> Thanks. i am totally lost
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
>
|
|
0
|
|
|
|
Reply
|
iebupdte
|
11/19/2009 8:39:23 PM
|
|
|
3 Replies
121 Views
(page loaded in 0.046 seconds)
|