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 15:33:16 -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"

No, this message has nothing to do with the data- it has to do with what length the variable is declared as by an informat or length statement when you defined state and hosp. If you are pretty sure the data will match, it probably isn't a problem.

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

Actually when I do merge I got the following WARNING log:

2779 data d.rate;

2780 merge state(in=f) hosp (in=d);

2781 by mem_id2_;

2782 if f=1 and d=1;

2783 run;

WARNING: Multiple lengths were specified for the BY variable MEM_ID2_ by input data sets. This

may cause unexpected results.

It makes me think that I should try just the very first letter of the first name +other part of the string.

Otherwise it may happend different length

How can I constract the very first letter of the name + year,month and gender ?

--- 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:37 PM

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.

------------------------------------------------------------------------------ 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