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 (November 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 8 Nov 2007 14:07:59 -0500
Reply-To:     Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:      Re: extracting from variables
Comments: To: Adriano Rodrigues <adriano@GPP.COM.BR>
In-Reply-To:  A<003901c82269$60fdb7d0$22f92770$@com.br>
Content-Type: text/plain; charset="us-ascii"

Andrio,

I think the problem is with the COMPRESS function. You are asking for all '(', 'N' and ')' characters to be removed from the string - hence the 'N' being removed from the start of 'NovaIguacu'.

Maybe you could use another function instead to remove the string '(N)'...

hometeam=tranwrd(homete,'(N)','');

Additionally, when I run your code I get Notes in the log about "invalid 3rd argument to function substring" where AWAYTE is being calculated. If you want all of the remaining string from the (H+1) point, you can eliminate the third argument.

awayte=substr(event,h+1);

Hope this helps.

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Adriano Rodrigues Sent: Thursday, November 08, 2007 7:42 PM To: SAS-L@LISTSERV.UGA.EDU Subject: extracting from variables

Hi SASlers,

I have the following:

Suppose I have variable event with some data like this:

data events;

length event$ 30.;

input event $;

cards;

NovaIguacu(N)$Fluminense

NovaIguacu(N)$Friburguense

NovaIguacu(N)$Madureira

NovaIguacu(N)$Vasco

Palmeiras$America FC SP

Palmeiras$Barueri(N)

;

proc freq;

run;

I want divide in 2 variables, home and away teams, then I tried:

data arruma;

set events;

h=find(event,'$',1);

homete=substr(event,1,h-1);

awayte=substr(event,h+1,100);

hometeam=compress(homete,'(N)');

awayteam=compress(awayte,'(N)');

proc freq;

table event hometeam awayteam;

run;

but now I saw compress take my N from start of names, like Nova Iguacu become ova Iguacu, I want remove exactly "(N)" from strings, what's the tricky I need learn?

Thanks in advance,

Adriano


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