Hi All,
=
I have a dataset with several thousand records and the first 3
variables. The only information I can send to a lab is the barcode.
However, I still need to tie the barcodes to each individual and each
collection date. Therefore, I hope to create 2 new variables as shown
in the last 2 columns.
=
Barcode ptid colldate subjid coll
123-123 111 1/10/2009 1 1
123-124 111 1/10/2009 1 1
123-125 111 2/15/2009 1 2
123-126 111 2/15/2009 1 2
123-127 123 1/12/2009 2 1
123-128 123 1/12/2009 2 1
123-129 123 3/10/2009 2 2
123-130 123 3/10/2009 2 2
123-131 123 3/10/2009 2 2
123-132 444 1/10/2009 3 1
123-133 444 1/10/2009 3 1
123-134 444 1/10/2009 3 1
.........
.........
=
Can anyone help me create the last two variables.?
=
Thanks.
Ann =
=
Ann Fowler
Clinical Data Coordinator III
Cystic Fibrosis Therapeutics Development Network
Coordinating Center
Seattle Children's Research Institute
1100 Olive Way, Suite 500
Seattle, WA 98101
email:ann.fowler@seattlechildrens.org
=
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is=
for the sole use of the intended recipient(s) and may contain confidential=
and privileged information protected by law. Any unauthorized review, use=
, disclosure or distribution is prohibited. If you are not the intended re=
cipient, please contact the sender by reply e-mail and destroy all copies o=
f the original message.
|
|
0
|
|
|
|
Reply
|
Ann
|
3/3/2010 6:50:44 PM |
|
Use BY and FIRST. This should work (untested):
data want;
set have;
by ptid colldate;
retain subjid 0;
if first.ptid then do;
subjid+1;
coll=0;
end;
if first.colldate then coll+1;
run;
first.colldate is true when reaching a new value for COLLDATE, or reaching a
new value for PTID (any var earlier in the BY statement). Similar for PTID.
-Joe
On Wed, Mar 3, 2010 at 12:50 PM, Fowler, Ann <
Ann.Fowler@seattlechildrens.org> wrote:
> Hi All,
>
>
>
> I have a dataset with several thousand records and the first 3
> variables. The only information I can send to a lab is the barcode.
> However, I still need to tie the barcodes to each individual and each
> collection date. Therefore, I hope to create 2 new variables as shown
> in the last 2 columns.
>
>
>
> Barcode ptid colldate subjid coll
>
> 123-123 111 1/10/2009 1 1
>
> 123-124 111 1/10/2009 1 1
>
> 123-125 111 2/15/2009 1 2
>
> 123-126 111 2/15/2009 1 2
>
> 123-127 123 1/12/2009 2 1
>
> 123-128 123 1/12/2009 2 1
>
> 123-129 123 3/10/2009 2 2
>
> 123-130 123 3/10/2009 2 2
>
> 123-131 123 3/10/2009 2 2
>
> 123-132 444 1/10/2009 3 1
>
> 123-133 444 1/10/2009 3 1
>
> 123-134 444 1/10/2009 3 1
>
> ........
>
> ........
>
>
>
> Can anyone help me create the last two variables.?
>
>
>
> Thanks.
>
> Ann
>
>
>
> Ann Fowler
>
> Clinical Data Coordinator III
>
> Cystic Fibrosis Therapeutics Development Network
>
> Coordinating Center
>
> Seattle Children's Research Institute
>
> 1100 Olive Way, Suite 500
>
> Seattle, WA 98101
>
> email:ann.fowler@seattlechildrens.org<email%3Aann.fowler@seattlechildrens.org>
>
>
>
>
>
> CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is
> for the sole use of the intended recipient(s) and may contain confidential
> and privileged information protected by law. Any unauthorized review, use,
> disclosure or distribution is prohibited. If you are not the intended
> recipient, please contact the sender by reply e-mail and destroy all copies
> of the original message.
>
|
|
0
|
|
|
|
Reply
|
snoopy369 (1752)
|
3/3/2010 6:54:29 PM
|
|
Ann
Try the following. I left your original "wanted" columns in place so that I could compare my results.
Nat Wooding
Data Ann;
informat Barcode $7. ptid 8. colldate mmddyy10. Wantedsubjid Wantedcoll;
input Barcode ptid colldate Wantedsubjid Wantedcoll;
Format colldate mmddyy10.;
cards;
123-123 111 1/10/2009 1 1
123-124 111 1/10/2009 1 1
123-125 111 2/15/2009 1 2
123-126 111 2/15/2009 1 2
123-127 123 1/12/2009 2 1
123-128 123 1/12/2009 2 1
123-129 123 3/10/2009 2 2
123-130 123 3/10/2009 2 2
123-131 123 3/10/2009 2 2
123-132 444 1/10/2009 3 1
123-133 444 1/10/2009 3 1
123-134 444 1/10/2009 3 1
;
Proc print;
run cancel ;
Data Wanted;
set ann;
by ptid notsorted colldate;
if first.ptid then do;
subjid + 1;
col1 = 0;
end;
if first.colldate then col1 + 1;
proc print;
run;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Fowler, Ann
Sent: Wednesday, March 03, 2010 1:51 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Creating new variables
Hi All,
I have a dataset with several thousand records and the first 3
variables. The only information I can send to a lab is the barcode.
However, I still need to tie the barcodes to each individual and each
collection date. Therefore, I hope to create 2 new variables as shown
in the last 2 columns.
Barcode ptid colldate subjid coll
123-123 111 1/10/2009 1 1
123-124 111 1/10/2009 1 1
123-125 111 2/15/2009 1 2
123-126 111 2/15/2009 1 2
123-127 123 1/12/2009 2 1
123-128 123 1/12/2009 2 1
123-129 123 3/10/2009 2 2
123-130 123 3/10/2009 2 2
123-131 123 3/10/2009 2 2
123-132 444 1/10/2009 3 1
123-133 444 1/10/2009 3 1
123-134 444 1/10/2009 3 1
.........
.........
Can anyone help me create the last two variables.?
Thanks.
Ann
Ann Fowler
Clinical Data Coordinator III
Cystic Fibrosis Therapeutics Development Network
Coordinating Center
Seattle Children's Research Institute
1100 Olive Way, Suite 500
Seattle, WA 98101
email:ann.fowler@seattlechildrens.org
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information protected by law. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
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)
|
3/3/2010 8:08:19 PM
|
|
|
2 Replies
144 Views
(page loaded in 0.204 seconds)
|