| Date: | Fri, 3 Aug 2001 15:29:15 -0400 |
| Reply-To: | "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM> |
| Subject: | Re: SUBSTRing with a leading / |
| Content-Type: | text/plain; charset="iso-8859-1" |
|---|
The first byte of Counties is a space, the second byte the slash delimiter.
Change to substr(Counties,3); and you'll get the results you want.
-----Original Message-----
From: Edward Heaton [mailto:HEATONE@WESTAT.COM]
Sent: August 3, 2001 3:07 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: SUBSTRing with a leading /
Greeting SAS Community;
I have a data set that looks like the following:
PSU County
1 A
1 A
1 B
1 B
2 C
3 D
3 E
3 E
3 E
3 F
I want to output the following:
PSU Counties
1 A/B
2 C
3 D/E/F
I tried the following:
Data result ;
Set test ;
By PSU County ;
Length Counties $8 ;
Retain Counties ;
If first.County then Counties = trim( Counties ) || "/" || County ;
If last.PSU then do ;
Counties = subStr( Counties , 2 ) ;
output ;
Counties = " " ;
End ;
Run ;
and got.
PSU Counties
1 /A/B
2 /C
3 /D/E/F
Why? I changed the SUBSTR function to start at the third character and got
the desired (but unexpected) result as follows.
PSU Counties
1 A/B
2 C
3 D/E/F
Any clues? Is SAS treating the leading "/" as an escape character or
something?
Ed
Edward Heaton, Senior Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1550 Research Boulevard, Room 2018, Rockville, MD 20850-3195
Voice: (301) 610-4818 Fax: (301) 294-3992
mailto:EdwardHeaton@westat.com http://www.westat.com
|