| Date: | Wed, 5 Oct 2011 10:01:46 -0400 |
| Reply-To: | sas quest <sasquest@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | sas quest <sasquest@GMAIL.COM> |
| Subject: | Re: No value on visits |
| In-Reply-To: | <FA0550A1D186FF49BB0748CD711B17EDC698887ACD@SDPSMSX.QUALNET.ORG> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
|---|
Thanks to you all. I appreciate your time.
I was trying to understand the doW loop solution by Toby which if understood
properly will be an elegant solution. It is giving me what I want but I am
struggling to
understand.Proc sql solution by Jim is by far the simplest way for me to
understand and apply.
Thanks once again.
On Wed, Oct 5, 2011 at 8:47 AM, Bian, Haikuo <HBian@flqio.sdps.org> wrote:
> Proc SQL sometimes is not as efficient, however, it can save some of your
> typing. Here is one approach:
>
> data a;
> input id $ test $ val visit $;
> cards;
> 001 A 1 1
> 001 B 2 1
> 001 C 3 1
> 001 A 2 2
> 001 B . 2
> 001 A 1 3
> 001 B 2 3
> 002 A 1 1
> 002 B 2 1
> 002 A . 2
> 002 B . 2
> 003 A 1 1
> 003 B 2 1
> 003 A . 2
> 003 B 2 2
> 004 A 1 1
> 004 B 2 1
> 004 C 3 1
> 004 A . 2
> 004 B . 2
> 004 C . 2
> ;
>
> proc sql;
> create table want as
> select * from a left join
> (select id, visit, ifc(sum(val)>.,'Not Missing', 'Missing') as flag
> from a group by id, visit) b
> on a.id=b.id and a.visit=b.visit;
> quit;
>
> proc print;run;
>
>
> Regards,
> Haikuo
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of sas
> quest
> Sent: Tuesday, October 04, 2011 3:39 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: No value on visits
>
> Hi,
> I have the following dataset. I want to know if any id had no values at a
> particular visit and identify that visit. Here id=002 and 004 need to be
> identified at visits 2 and flagged.
>
> *data* a;
> input id test $ val visit;
> cards;
> 001 A 1 1
> 001 B 2 1
> 001 C 3 1
> 001 A 2 2
> 001 B . 2
> 001 A 1 3
> 001 B 2 3
> 002 A 1 1
> 002 B 2 1
> 002 A . 2
> 002 B . 2
> 003 A 1 1
> 003 B 2 1
> 003 A . 2
> 003 B 2 2
> 004 A 1 1
> 004 B 2 1
> 004 C 3 1
> 004 A . 2
> 004 B . 2
> 004 C . 2
> ;
> *run*;
>
> Thanks in advance.
>
> I tried the following but didnt quite work
>
> *
>
> data* b;
>
> array test(*) $ A B C;
>
> do i=*1* to *3*;
>
> set a;
>
> test(i)=val; ;end;
>
> if A='' and B='' and C='' then flag=1;
> *
>
> run*;
> -----------------------------------------
> Email messages cannot be guaranteed to be secure or error-free as
> transmitted information can be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses. The
> Centers for Medicare & Medicaid Services therefore does not accept
> liability for any error or omissions in the contents of this
> message, which arise as a result of email transmission.
>
> CONFIDENTIALITY NOTICE: This communication, including any
> attachments, may contain confidential information and is intended
> only for the individual or entity to which it is addressed. Any
> review, dissemination, or copying of this communication by anyone
> other than the intended recipient is strictly prohibited. If you
> are not the intended recipient, please contact the sender by reply
> email and delete and destroy all copies of the original message.
>
|