LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 1 May 2008 14:37:39 -0500
Reply-To:   Mary <mlhoward@avalon.net>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mary <mlhoward@AVALON.NET>
Subject:   Re: How to take out the part of the string ID? Need help.
Comments:   To: irinfigvam@yahoo.com
Content-Type:   text/plain; charset="iso-8859-1"

Same principle; using the lengthn function, the check for >=12 is there to account for names less than 5 long.

data set1;

informat name $200.;

infile cards;

input name;

if lengthn(name) >=12 then

name=substr(name,1,5) || substr(name,lengthn(name)-6,7);

cards;

Evangelina194511F

Ann194511F

;

run;

-Mary

----- Original Message ----- From: Irin later To: SAS-L@LISTSERV.UGA.EDU ; Mary Sent: Thursday, May 01, 2008 2:25 PM Subject: Re: How to take out the part of the string ID? Need help.

Mary, it does work! Thank you so much!

I just realized that I have one more problem. Woul you be so kind as to help me with that?

I compare two files and it appears that id on the other side have longer name:

Evangelina194511F

How can I constract it in order to have just 5 letters of the name:

Evang194511F

Thank you for ALL YOUR HELP!

Irin

--- On Thu, 5/1/08, Mary <mlhoward@avalon.net> wrote:

From: Mary <mlhoward@avalon.net> Subject: Re: How to take out the part of the string ID? Need help. To: irinfigvam@yahoo.com, SAS-L@LISTSERV.UGA.EDU Date: Thursday, May 1, 2008, 3:05 PM

data set1;

informat name $200.;

infile cards;

input name;

name=substr(name,1,lengthn(name)-3) || substr(name,lengthn(name),lengthn(name));

cards;

ADAM19480204M

;

run;

-Mary

----- Original Message ----- From: Irin later To: SAS-L@LISTSERV.UGA.EDU Sent: Thursday, May 01, 2008 1:15 PM Subject: How to take out the part of the string ID? Need help.

I have newid for example

ADAM19480204M (name+year+month+day+gender)

I need to rebuild it in order it looks like:

ADAM194802M (name+year+month+gender)

(Name can vary up to 5 letters)

In other words I need to take out DAY part.

Could you give me a hand ,please , with this code?

Thank you in advance, Irin

-------------------------------------------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.

------------------------------------------------------------------------------ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


Back to: Top of message | Previous page | Main SAS-L page