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 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 14 May 2009 12:48:53 -0700
Reply-To:     "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Terjeson, Mark" <Mterjeson@RUSSELL.COM>
Subject:      Re: A Substring Function question
Comments: To: Tom Smith <need_sas_help@YAHOO.COM>
In-Reply-To:  A<200905141943.n4EJX426030601@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Hi Tom,

Here are several ways:

data sample; input appe $ charie $; cards; R102 co1 R102 co3 R201 co5 R205 co7 ; run;

data result1; set sample; if appe eq: 'R1'; run;

data result2; set sample; if substr(appe,1,2) eq 'R1'; run;

proc sql; create table result3 as select * from sample where appe eqt 'R1' ; quit;

proc sql; create table result4 as select * from sample where substr(appe,1,2) eq 'R1' ; quit;

proc sql; create table result5 as select * from sample where appe like 'R1%' ; quit;

Hope this is helpful.

Mark Terjeson Investment Business Intelligence Investment Management & Research Russell Investments 253-439-2367

Russell Global Leaders in Multi-Manager Investing

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Tom Smith Sent: Thursday, May 14, 2009 12:43 PM To: SAS-L@LISTSERV.UGA.EDU Subject: A Substring Function question

I have a follwoing dataset:

appe charie ---- ------ R102 co1 R102 co3 R201 co5 R205 co7

Now I need to use substring function so I can subset only the obsevations which has first two character of the variable apple "R1". So myfinal dataset would be as below:

appe charie ---- ------ R102 co1 R102 co3

Thanks you


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