Date: Wed, 25 May 2011 00:28:00 +0530
Reply-To: vaibhav wadhera <vaibhavwadhera@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: vaibhav wadhera <vaibhavwadhera@GMAIL.COM>
Subject: Re: Simple SAS Problem
In-Reply-To: <FA0550A1D186FF49BB0748CD711B17EDB2A9426CA9@SDPSMSX.QUALNET.ORG>
Content-Type: text/plain; charset=ISO-8859-1
Hi
What i need is that in the Input dataset you can see that we have
3 participants
991 has 2 rows one for TYPENR as 01 and other for the 02. So i need to have
in the output only single row for them with 4 different variables with
TYPE_NR_MEDICAL and OPT_NR_MEDICAL for the typenr 01 row popualted values
and TYPE_NR_DENTAL and OPT_NR_DENTAL with the dental information.
ALso for the 992 u can see that we do not have the 02 typenr row in the
input so the TYPE_NR_DENTAL and OPT_NR_DENTAL should be blank and its there
with my code.
but for the 993 we have the 02 typenr row and but 01 typenr row is not there
but then also in the output TYPE_NR_MEDICAL and OPT_NR_MEDICAL are getting
populated with the values of the previous observation.
On Wed, May 25, 2011 at 12:20 AM, Bian, Haikuo <HBian@flqio.sdps.org> wrote:
> From what you have presented, it is hard for me to determine what you
> really want. It seems to me that you only want the first record to be
> populated with "TYPE_NR_DENTAL" and " OPT_NR_DENTAL" and rest of them to be
> left blank. If so (although I can hardly imagine why), the following
> modification of your code should be working for you:
>
> DATA LOW (drop =i);
> SET HIGH;RETAIN TYPE_NR_MEDICAL OPT_NR_MEDICAL ;
>
> BY PRSN_ID TYPE_NR;
> IF FIRST.PRSN_ID THEN DO;
>
> IF TYPE_NR = '01' THEN TYPE_NR_MEDICAL = TYPE_NR;
> IF OPT_NR = '02' THEN OPT_NR_MEDICAL =OPT_NR;
> END;
> IF LAST.PRSN_ID then do;
> i+1;
> if i=1 THEN DO;
> IF TYPE_NR= '02' THEN TYPE_NR_DENTAL= TYPE_NR;
> IF OPT_NR = '03' THEN OPT_NR_DENTAL =OPT_NR;
> OUTPUT LOW; end;
> else if i>1 then output low;
> END;
>
>
> HTH,
> Haikuo
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> vaibhav wadhera
> Sent: Tuesday, May 24, 2011 2:23 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Simple SAS Problem
>
> Hi
>
> I have following code
>
>
> DATA HIGH;
> INPUT PRSN_ID TYPE_NR $ OPT_NR $;
> DATALINES;
> 991 01 02
> 991 02 03
> 992 01 02
> 993 02 03
> ;
> RUN;
>
> PROC SORT DATA=HIGH;
> BY PRSN_ID TYPE_NR;
> RUN;
>
> DATA LOW;
> SET HIGH;
> BY PRSN_ID TYPE_NR;
> IF FIRST.PRSN_ID THEN DO;
> RETAIN TYPE_NR_MEDICAL OPT_NR_MEDICAL ;
>
> IF TYPE_NR = '01' THEN TYPE_NR_MEDICAL = TYPE_NR;
> IF OPT_NR = '02' THEN OPT_NR_MEDICAL =OPT_NR;
> END;
> IF LAST.PRSN_ID THEN DO;
> IF TYPE_NR= '02' THEN TYPE_NR_DENTAL= TYPE_NR;
> IF OPT_NR = '03' THEN OPT_NR_DENTAL =OPT_NR;
> OUTPUT LOW;
> END;
>
> PROC PRINT DATA=LOW;
> RUN;
>
> And the results i am getting are
> TYPE_NR_ OPT_NR_
> TYPE_NR_ OPT_NR_
> Obs PRSN_ID TYPE_NR OPT_NR MEDICAL MEDICAL
> DENTAL DENTAL
>
> 1 991 02 03 01 02
> 02 03
> 2 992 01 02 01 02
> 3 993 02 03 01 02
> 02 03
> --
> But i need
>
> TYPE_NR_ OPT_NR_
> TYPE_NR_ OPT_NR_
> Obs PRSN_ID TYPE_NR OPT_NR MEDICAL MEDICAL
> DENTAL DENTAL
>
> 1 991 02 03 01 02
> 02 03
> 2 992 01 02 01 02
> 3 993 02 03
> 02 03
>
> Please have a look
>
> Thanks & Regards
>
> Vaibhav wadhera
> -----------------------------------------
> 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.
>
--
Thanks & Regards
Vaibhav wadhera
|