Center for Health Program Development and Management
University of Maryland, Baltimore County
=20
________________________________
From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of Irin later Sent: Wednesday, April 23, 2008 8:36 AM To: SA...@LISTSERV.UGA.EDU Subject: How to construct the string ID ?
=20
I have ID that includes a name, year of birth, month of birch an gender
LOLOBRIDGIDA195703F
=20
I need to construct id of just 5 letters of that first name and the rest of the ID above:
LOLOB195703F
=20
How can I implement it with a code (I mean all names has different length)?
<table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font: inherit;'><DIV id=yiv1114131686> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3> </FONT><FONT face="Times New Roman" size=3>I have ID that includes a name, year of birth, month of birch an gender</FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>LOLOBRIDGIDA195703F</FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3></FONT> </P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>I need to construct id<SPAN> </SPAN>of just 5 letters of that first name and the rest of the ID above:</FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>LOLOB195703F</FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3> </FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>How can I implement it with a code (I mean all names has different length)?</FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3> </FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3>Thank you in advance,</FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3> </FONT></P> <P class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT size=3><FONT face="Times New Roman">Irin</FONT></FONT></P></DIV></td></tr></table><br>
You could write this out in one statement but I find it easier to understand and follow if I see the parts.
Data newid;
string ='LOLOBRIDGIDA195703F';
name = substr( string , 1 , 5 ); * extract five letters of the name; string = reverse( string ); * reverse the string so that you may read from the right; stats = reverse( substr( string , 1 , 7 )); * read the needed info and reverse; newid = compress( name || stats) ; * create the new variable; Drop stats name; run;
Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977
Irin later <irinfigvam@YAHOO .COM> To Sent by: "SAS(r) SA...@LISTSERV.UGA.EDU Discussion" cc <SA...@LISTSERV.U GA.EDU> Subject How to construct the string ID ?
04/23/2008 08:35 AM
Please respond to irinfigvam@yahoo. com
I have ID that includes a name, year of birth, month of birch an gender LOLOBRIDGIDA195703F
I need to construct id of just 5 letters of that first name and the rest of the ID above: LOLOB195703F
How can I implement it with a code (I mean all names has different length)?
Thank you in advance,
Irin
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
----------------------------------------- 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.
<table cellspacing=3D'0' cellpadding=3D'0' border=3D'0' ><tr><td style=3D'f= ont: inherit;'><P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT fac= e=3D"Times New Roman" size=3D3>Jack, I do not have spaces, but scenarion wi= th less than 5 letters did not even come to my mind .It actually can= =E2=80=A6.</FONT></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><?xml:namespace prefix = =3D o ns =3D "urn:schemas-microsoft-com:office:office" /><o:p><FONT face=3D= "Times New Roman" size=3D3> </FONT></o:p></P> <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT face=3D"Times New = Roman" size=3D3>Is it possible to do it in such a case?</FONT></P><BR><BR>-= -- On <B>Wed, 4/23/08, Jack Clark <I><JCl...@CHPDM.UMBC.EDU></I></B> = wrote:<BR> <BLOCKQUOTE style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(= 16,16,255) 2px solid">From: Jack Clark <JCl...@CHPDM.UMBC.EDU><BR>Sub= ject: Re: How to construct the string ID ?<BR>To: SA...@LISTSERV.UGA.EDU<BR=
>Date: Wednesday, April 23, 2008, 8:49 AM<BR><BR><PRE>Irin,
=20
This assumes no missing characters in the ID structure you described and no names less than 5 characters.
Center for Health Program Development and Management
University of Maryland, Baltimore County
=20
________________________________
From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of Irin later Sent: Wednesday, April 23, 2008 8:36 AM To: SA...@LISTSERV.UGA.EDU Subject: How to construct the string ID ?
=20
I have ID that includes a name, year of birth, month of birch an gender
LOLOBRIDGIDA195703F
=20
I need to construct id of just 5 letters of that first name and the rest of the ID above:
LOLOB195703F
=20
How can I implement it with a code (I mean all names has different length)?
>Nat Wooding >Environmental Specialist III >Dominion, Environmental Biology >4111 Castlewood Rd >Richmond, VA 23234 >Phone:804-271-5313, Fax: 804-271-2977
> Irin later > <irinfigvam@YAHOO > .COM> To > Sent by: "SAS(r) SA...@LISTSERV.UGA.EDU > Discussion" cc > <SA...@LISTSERV.U > GA.EDU> Subject > Re: How to construct the string ID > ? > 04/23/2008 09:14 > AM
> Please respond to > irinfigvam@yahoo. > com
> Jack, I do not have spaces, but scenarion with less than 5 letters did not > even come to my mind .It actually can….
> Is it possible to do it in such a case?
> --- On Wed, 4/23/08, Jack Clark <JCl...@CHPDM.UMBC.EDU> wrote: > From: Jack Clark <JCl...@CHPDM.UMBC.EDU> > Subject: Re: How to construct the string ID ? > To: SA...@LISTSERV.UGA.EDU > Date: Wednesday, April 23, 2008, 8:49 AM
> Irin,
> This assumes no missing characters in the ID structure you described and > no names less than 5 characters.
> Center for Health Program Development and Management
> University of Maryland, Baltimore County
> ________________________________
> From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of > Irin later > Sent: Wednesday, April 23, 2008 8:36 AM > To: SA...@LISTSERV.UGA.EDU > Subject: How to construct the string ID ?
> I have ID that includes a name, year of birth, month of birch an gender
> LOLOBRIDGIDA195703F
> I need to construct id of just 5 letters of that first name and the > rest of the ID above:
> LOLOB195703F
> How can I implement it with a code (I mean all names has different > length)?
>Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it >now. >----------------------------------------- >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.
If modified, Pauls code works nicely with fewer than five letters and an internal space
Data newid;
id ='L LO195703F';
NewID = cats( compress( substr (ID, 1, 5) , '0123456789' ), substr (ID, anydigit (ID) )) ; put newid; run;
Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977
Irin later <irinfigvam@YAHOO .COM> To Sent by: "SAS(r) SA...@LISTSERV.UGA.EDU Discussion" cc <SA...@LISTSERV.U GA.EDU> Subject Re: How to construct the string ID ? 04/23/2008 09:14 AM
Please respond to irinfigvam@yahoo. com
Jack, I do not have spaces, but scenarion with less than 5 letters did not even come to my mind .It actually can….
Is it possible to do it in such a case?
--- On Wed, 4/23/08, Jack Clark <JCl...@CHPDM.UMBC.EDU> wrote: From: Jack Clark <JCl...@CHPDM.UMBC.EDU> Subject: Re: How to construct the string ID ? To: SA...@LISTSERV.UGA.EDU Date: Wednesday, April 23, 2008, 8:49 AM
Irin,
This assumes no missing characters in the ID structure you described and no names less than 5 characters.
Center for Health Program Development and Management
University of Maryland, Baltimore County
________________________________
From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of Irin later Sent: Wednesday, April 23, 2008 8:36 AM To: SA...@LISTSERV.UGA.EDU Subject: How to construct the string ID ?
I have ID that includes a name, year of birth, month of birch an gender
LOLOBRIDGIDA195703F
I need to construct id of just 5 letters of that first name and the rest of the ID above:
LOLOB195703F
How can I implement it with a code (I mean all names has different length)?
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ----------------------------------------- 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.
The elegant substr(ID,anydigit) technique proposed by Paul and modified by Howard also assumes no one has a numeric character in their name. Want to bet on that?
If you don't, then you have to go to the more ugly approach of explicitly extracting the last 7 characters (the "YYYYMMX" at the end). This function will deal with that.
I'd also suggest that you might want all the NEWID's to have the same length, which won't happen with short names. In that case, let's say you want to put an underscore as a filler whenever the name part of the id is too short. Which would introduce the complications in this version:
-----Original Message----- From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of Howard Schreier <hs AT dc-sug DOT org> Sent: Wednesday, April 23, 2008 9:27 AM To: SA...@LISTSERV.UGA.EDU Subject: Re: How to construct the string ID ?
data _null_; do ID = 'Goodnight123456A', 'Sall234567B'; NewID = cats (substr (ID, 1, min(anydigit (ID) - 1, 5) ) , substr (ID, anydigit (ID) ) ); put id= newid=; end; run;
>Nat Wooding >Environmental Specialist III >Dominion, Environmental Biology >4111 Castlewood Rd >Richmond, VA 23234 >Phone:804-271-5313, Fax: 804-271-2977
> Irin later > <irinfigvam@YAHOO > .COM> To > Sent by: "SAS(r) SA...@LISTSERV.UGA.EDU > Discussion" cc > <SA...@LISTSERV.U > GA.EDU> Subject > Re: How to construct the string ID > ? > 04/23/2008 09:14 > AM
> Please respond to > irinfigvam@yahoo. > com
> Jack, I do not have spaces, but scenarion with less than 5 letters did not > even come to my mind .It actually can….
> Is it possible to do it in such a case?
> --- On Wed, 4/23/08, Jack Clark <JCl...@CHPDM.UMBC.EDU> wrote: > From: Jack Clark <JCl...@CHPDM.UMBC.EDU> > Subject: Re: How to construct the string ID ? > To: SA...@LISTSERV.UGA.EDU > Date: Wednesday, April 23, 2008, 8:49 AM
> Irin,
> This assumes no missing characters in the ID structure you described and > no names less than 5 characters.
> Center for Health Program Development and Management
> University of Maryland, Baltimore County
> ________________________________
> From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of > Irin later > Sent: Wednesday, April 23, 2008 8:36 AM > To: SA...@LISTSERV.UGA.EDU > Subject: How to construct the string ID ?
> I have ID that includes a name, year of birth, month of birch an gender
> LOLOBRIDGIDA195703F
> I need to construct id of just 5 letters of that first name and the > rest of the ID above:
> LOLOB195703F
> How can I implement it with a code (I mean all names has different > length)?
>Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it >now. >----------------------------------------- >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.
Seems like you can take advantage of the fact the the part at the end is constant length. YYYYMMG. I would also suggest that any ID less than length 12 needs no modification. But I include at bit of code that to address that situation that seems adequate in belated offering.
459 data _null_; 460 length id ref $50; 461 input id @1 ref; 462 if length(id) gt 12 then substr(id,6)=substr(id,length(id)-6); 463 else id = subpad(substr(id,1,length(id)-7),1,5)||substr(id,length(id)-6); 464 put (_all_)(:); 465 cards;
LOLOB195703F LOLOBRIDGIDA195703F DudeB200804M DudeBornYesterday200804M Dude 200804M Dude200804M Du 200804M Du200804M
On Wed, Apr 23, 2008 at 8:26 AM, Howard Schreier <hs AT dc-sug DOT
> > Irin later > > <irinfigvam@YAHOO > > .COM> To > > Sent by: "SAS(r) SA...@LISTSERV.UGA.EDU > > Discussion" cc > > <SA...@LISTSERV.U > > GA.EDU> Subject > > Re: How to construct the string ID > > ? > > 04/23/2008 09:14 > > AM
> > Please respond to > > irinfigvam@yahoo. > > com
> > Jack, I do not have spaces, but scenarion with less than 5 letters did not > > even come to my mind .It actually can….
> > Is it possible to do it in such a case?
> > --- On Wed, 4/23/08, Jack Clark <JCl...@CHPDM.UMBC.EDU> wrote: > > From: Jack Clark <JCl...@CHPDM.UMBC.EDU> > > Subject: Re: How to construct the string ID ? > > To: SA...@LISTSERV.UGA.EDU > > Date: Wednesday, April 23, 2008, 8:49 AM
> > Irin,
> > This assumes no missing characters in the ID structure you described and > > no names less than 5 characters.
> > Center for Health Program Development and Management
> > University of Maryland, Baltimore County
> > ________________________________
> > From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of > > Irin later > > Sent: Wednesday, April 23, 2008 8:36 AM > > To: SA...@LISTSERV.UGA.EDU > > Subject: How to construct the string ID ?
> > I have ID that includes a name, year of birth, month of birch an gender
> > LOLOBRIDGIDA195703F
> > I need to construct id of just 5 letters of that first name and the > > rest of the ID above:
> > LOLOB195703F
> > How can I implement it with a code (I mean all names has different > > length)?
> >Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > >now. > >----------------------------------------- > >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.
<table cellspacing=3D'0' cellpadding=3D'0' border=3D'0' ><tr><td style=3D'f= ont: inherit;'><P>A this time I have newid (name+year+month+day= +gender) r example ADAM19480204M</P> <P>I need to rebuild it in order it looks like:</P> <P> </P> <P> ADAM194802M</P> <P>(Name can vary up to 5 letters)</P> <P> </P> <P>In other words I need to take out DAY part.</P> <P> </P> <P>Could you give me a hand ,please , with this code?</P> <P> </P> <P>Thank you in advance,</P> <P> </P> <P>Irin</P> <P> </P> <P><BR><BR>--- On <B>Wed, 4/23/08, Nathaniel.Wood...@dom.com <I><Nathani=
<BLOCKQUOTE style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(= 16,16,255) 2px solid">From: Nathaniel.Wood...@dom.com <Nathaniel.Wooding= @dom.com><BR>Subject: Re: How to construct the string ID ?<BR>To: irinfi= g...@yahoo.com<BR>Cc: SA...@LISTSERV.UGA.EDU<BR>Date: Wednesday, April 23, = 2008, 9:22 AM<BR><BR><PRE>If modified, Pauls code works nicely with fewer t= han five letters and an internal space
Data newid;
id =3D'L LO195703F';
NewID =3D cats( compress( substr (ID, 1, 5) , '0123456789' ), substr (ID, anydigit (ID) )) ; put newid; run;
Nat Wooding Environmental Specialist III Dominion, Environmental Biology 4111 Castlewood Rd Richmond, VA 23234 Phone:804-271-5313, Fax: 804-271-2977
= =20 Irin later = =20 <irinfigvam@YAHOO = =20 .COM> = To=20 Sent by: "SAS(r) SA...@LISTSERV.UGA.EDU = =20
Discussion" cc
<SA...@LISTSERV.U = =20 GA.EDU> Subje= ct=20 Re: How to construct the string ID = =20 ? = =20 04/23/2008 09:14 = =20 AM = =20 = =20 = =20 Please respond to = =20 irinfigvam@yahoo. = =20 com = =20 = =20 = =20
= =20 Jack, I do not have spaces, but scenarion with less than 5 letters did not= =20 even come to my mind .It actually can=E2=80=A6. = =20 = =20 Is it possible to do it in such a case? = =20 = =20 = =20 = =20 = =20 --- On Wed, 4/23/08, Jack Clark <JCl...@CHPDM.UMBC.EDU> wrote: = =20 =20 From: Jack Clark <JCl...@CHPDM.UMBC.EDU> = =20 =20 Subject: Re: How to construct the string ID ? = =20 To: SA...@LISTSERV.UGA.EDU = =20 Date: Wednesday, April 23, 2008, 8:49 AM = =20 = =20 Irin, = =20 = =20 = =20 = =20 This assumes no missing characters in the ID structure you described and = =20 no names less than 5 characters. = =20 = =20 = =20 = =20 data _null_; = =20 = =20 length id2 $12; = =20 = =20 id =3D 'LOLOBRIDGIDA195703F'; =20 =20 = =20 id2 =3D substr(id,1,5)||reverse((substr(reverse(id),1,7))); = =20 = =20 put _all_; = =20 = =20 run; = =20 = =20 = =20 = =20 = =20 = =20 Jack Clark = =20 = =20 Research Analyst = =20 = =20 Center for Health Program Development and Management = =20 = =20 University of Maryland, Baltimore County = =20 = =20 = =20 = =20 ________________________________ = =20 = =20 From: SAS(r) Discussion [mailto:SA...@LISTSERV.UGA.EDU] On Behalf Of = =20 Irin later = =20 Sent: Wednesday, April 23, 2008 8:36 AM = =20 To: SA...@LISTSERV.UGA.EDU = =20 Subject: How to construct the string ID ? = =20 = =20 = =20 = =20 I have ID that includes a name, year of birth, month of birch an gender = =20 = =20 LOLOBRIDGIDA195703F = =20 = =20 = =20 = =20 I need to construct id of just 5 letters of that first name and the = =20 rest of the ID above: = =20 = =20 LOLOB195703F = =20 = =20 = =20 = =20 How can I implement it with a code (I mean all names has different = =20 length)? = =20 = =20 = =20 = =20 Thank you in advance, = =20 = =20 = =20 = =20 Irin = =20 = =20 = =20 = =20 ________________________________ = =20
<table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font: inherit;'><P>Paul, but I do not see the new id!!!!</P> <P> </P> <P>Fin has just Gender letter! I am not sure if I properly explained the issue</P> <P> </P> <P>This is my old id</P> <P> </P> <P>ADAM19480204M</P> <P>This should be my new id </P> <P>ADAM194802M (Short one without "04" - day):</P> <P> </P> <P> </P> <P>SESIL20071210F </P> <P>SESIL200712F (short one without "10" - day):</P> <P> </P> <P>Sesil name is longer (5 letters)</P> <P><BR><BR>--- On <B>Thu, 5/1/08, Paul St Louis <I><pstl...@DOT.STATE.TX.US></I></B> wrote:<BR></P> <BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">From: Paul St Louis <pstl...@DOT.STATE.TX.US><BR>Subject: Re: How to construct the string ID ?<BR>To: SA...@LISTSERV.UGA.EDU<BR>Date: Thursday, May 1, 2008, 2:28 PM<BR><BR><PRE>Hi Irin,
I am using Windows XP and SAS 9.1...I think this might get what you want.
Data Have; Input @1 Old $14.;
Datalines; Adam19480204m Stlo19620408m ;
Data Need (Drop = Temp1 Temp2 New); Length New $14.; Set Have; Temp1 = Left(Reverse(Old)); Sex = Substr(Temp1,1,1); Temp2 = Substr(Temp1,4,10); New = Reverse(Temp2); Fin = Cats(New,Sex); Run;
Proc Print; Var Old Fin Sex; Run;
On Thu, 1 May 2008 10:47:13 -0700, Irin later <irinfig...@YAHOO.COM> wrote:
><table cellspacing='0' cellpadding='0'
border='0' ><tr><td style='font: inherit;'><P>A this time I have newid (name+year+month+day+gender) r example ADAM19480204M</P>
><P>I need to rebuild it in order it looks like:</P> ><P> </P> ><P> ADAM194802M</P> ><P>(Name can vary up to 5 letters)</P> ><P> </P> ><P>In other words I need to take out DAY part.</P> ><P> </P> ><P>Could you give me a hand ,please , with this code?</P> ><P> </P> ><P>Thank you in advance,</P> ><P> </P> ><P>Irin</P> ><P> </P></PRE></BLOCKQUOTE></td></tr></table><br>
I am using Windows XP and SAS 9.1...I think this might get what you want.
Data Have; Input @1 Old $14.;
Datalines; Adam19480204m Stlo19620408m ;
Data Need (Drop = Temp1 Temp2 New); Length New $14.; Set Have; Temp1 = Left(Reverse(Old)); Sex = Substr(Temp1,1,1); Temp2 = Substr(Temp1,4,10); New = Reverse(Temp2); Fin = Cats(New,Sex); Run;
Proc Print; Var Old Fin Sex; Run;
On Thu, 1 May 2008 10:47:13 -0700, Irin later <irinfig...@YAHOO.COM> wrote: ><table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font:
inherit;'><P>A this time I have newid (name+year+month+day+gender) r example ADAM19480204M</P>
><P>I need to rebuild it in order it looks like:</P> ><P> </P> ><P> ADAM194802M</P> ><P>(Name can vary up to 5 letters)</P> ><P> </P> ><P>In other words I need to take out DAY part.</P> ><P> </P> ><P>Could you give me a hand ,please , with this code?</P> ><P> </P> ><P>Thank you in advance,</P> ><P> </P> ><P>Irin</P> ><P> </P>
It's been very busy around here, but I should explain the code a little bit more. The code that I wrote is reversing the order of the variable and trimming it down.
Temp1 = Left(Reverse(Old));
Next, isolate M or F.
Sex = Substr(Temp1,1,1);
Now skip 4 characters over and read the rest
Temp2 = Substr(Temp1,4,10);
Now place it back in the original order (could have said temp2 = reverse (temp2), but wanted to break out the process so you could see it)
New = Reverse(Temp2);
Use Cats to remove leading and trailing blanks and || together the two variables into one
Fin = Cats(New,Sex);
Clear as mud?
>>> Irin later <irinfig...@yahoo.com> 05/01/2008 1:49 PM >>>
Paul, but I do not see the new id!!!!
Fin has just Gender letter! I am not sure if I properly explained the issue
This is my old id
ADAM19480204M This should be my new id ADAM194802M (Short one without "04" - day):
SESIL20071210F SESIL200712F (short one without "10" - day):